[JS IR] Add -Xgenerate-dts CLI argument
This commit is contained in:
+16
-2
@@ -13,7 +13,21 @@ import java.util.zip.ZipFile
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true)
|
||||
class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
@Test
|
||||
fun generateDts() {
|
||||
val project = Project("kotlin2JsIrDtsGeneration")
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
checkIrCompilationMessage()
|
||||
|
||||
assertFileExists("build/kotlin2js/main/lib.js")
|
||||
val dts = fileInWorkingDir("build/kotlin2js/main/lib.d.ts")
|
||||
assert(dts.exists())
|
||||
assert(dts.readText().contains("function bar(): string"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@Test
|
||||
@@ -119,7 +133,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(private val irBackend: Boolean) :
|
||||
override fun defaultBuildOptions(): BuildOptions =
|
||||
super.defaultBuildOptions().copy(jsIrBackend = irBackend)
|
||||
|
||||
private fun CompiledProject.checkIrCompilationMessage() {
|
||||
protected fun CompiledProject.checkIrCompilationMessage() {
|
||||
if (irBackend) {
|
||||
assertContains(USING_JS_IR_BACKEND_MESSAGE)
|
||||
} else {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin2js"
|
||||
apply plugin: 'java'
|
||||
|
||||
def outDir = "${buildDir}/kotlin2js/main/"
|
||||
compileKotlin2Js.kotlinOptions.moduleKind = "plain"
|
||||
compileKotlin2Js.kotlinOptions.outputFile = outDir + "lib.js"
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js", "-Xgenerate-dts"]
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package foo
|
||||
|
||||
@JsExport
|
||||
fun bar() = "OK"
|
||||
Reference in New Issue
Block a user