[K/JS] Add ability to exclude declarations from export by a new annotation @JsExport.Ignore.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
@JsExport
|
||||
class Bar(val value: String) {
|
||||
@JsExport.Ignore
|
||||
constructor(): this("SECONDARY")
|
||||
|
||||
@JsExport.Ignore
|
||||
val excludedValue: Int = 42
|
||||
|
||||
fun foo(): String = "FOO"
|
||||
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "EXCLUDED_FUN"
|
||||
|
||||
class Nested
|
||||
|
||||
@JsExport.Ignore
|
||||
class ExcludedNested {
|
||||
fun doSomething(): String = "SOMETHING"
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun baz(): String = "BAZ"
|
||||
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "STATIC EXCLUDED_FUN"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.js
|
||||
function box() {
|
||||
var Bar = this.lib.Bar;
|
||||
var bar = new Bar("TEST");
|
||||
|
||||
if (bar.value !== "TEST") return "Error: exported property was not exported"
|
||||
if (bar.excludedValue === 42) return "Error: not exported property was exported"
|
||||
|
||||
if (bar.foo() !== "FOO") return "Error: exported function was not exported"
|
||||
if (typeof bar.excludedFun === "function") return "Error: not exported function was exported"
|
||||
|
||||
if (typeof Bar.Nested !== "function") return "Error: exported nested class was not exported"
|
||||
if (typeof Bar.ExcludedNested === "function") return "Error: not exported nested class was exported"
|
||||
|
||||
if (Bar.Companion.baz() !== "BAZ") return "Error: exported companion function was not exported"
|
||||
if (typeof Bar.Companion.excludedFun === "function") return "Error: not exported companion function was exported"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
@file:JsExport
|
||||
|
||||
val value: String = "TEST"
|
||||
|
||||
@JsExport.Ignore
|
||||
val excludedValue: Int = 42
|
||||
|
||||
fun foo(): String = "FOO"
|
||||
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "EXCLUDED_FUN"
|
||||
|
||||
class SomeClass
|
||||
|
||||
@JsExport.Ignore
|
||||
class ExcludedSomeClass {
|
||||
fun doSomething(): String = "SOMETHING"
|
||||
}
|
||||
|
||||
object Companion {
|
||||
fun baz(): String = "BAZ"
|
||||
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "STATIC EXCLUDED_FUN"
|
||||
}
|
||||
|
||||
// FILE: main.js
|
||||
function box() {
|
||||
var lib = this.lib;
|
||||
|
||||
if (lib.value !== "TEST") return "Error: exported property was not exported"
|
||||
if (lib.excludedValue === 42) return "Error: not exported property was exported"
|
||||
|
||||
if (lib.foo() !== "FOO") return "Error: exported function was not exported"
|
||||
if (typeof lib.excludedFun === "function") return "Error: not exported function was exported"
|
||||
|
||||
if (typeof lib.SomeClass !== "function") return "Error: exported nested class was not exported"
|
||||
if (typeof lib.ExcludedSomeClass === "function") return "Error: not exported nested class was exported"
|
||||
|
||||
if (lib.Companion.baz() !== "BAZ") return "Error: exported companion function was not exported"
|
||||
if (typeof lib.Companion.excludedFun === "function") return "Error: not exported companion function was exported"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@JsExport
|
||||
val value: String = "TEST"
|
||||
|
||||
@JsExport
|
||||
@JsExport.Ignore
|
||||
val excludedValue: Int = 42
|
||||
|
||||
@JsExport
|
||||
fun foo(): String = "FOO"
|
||||
|
||||
@JsExport
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "EXCLUDED_FUN"
|
||||
|
||||
@JsExport
|
||||
class SomeClass
|
||||
|
||||
@JsExport.Ignore
|
||||
@JsExport
|
||||
class ExcludedSomeClass {
|
||||
fun doSomething(): String = "SOMETHING"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
object Companion {
|
||||
fun baz(): String = "BAZ"
|
||||
|
||||
@JsExport.Ignore
|
||||
fun excludedFun(): String = "STATIC EXCLUDED_FUN"
|
||||
}
|
||||
|
||||
// FILE: main.js
|
||||
function box() {
|
||||
var lib = this.lib;
|
||||
|
||||
if (lib.value !== "TEST") return "Error: exported property was not exported"
|
||||
if (lib.excludedValue === 42) return "Error: not exported property was exported"
|
||||
|
||||
if (lib.foo() !== "FOO") return "Error: exported function was not exported"
|
||||
if (typeof lib.excludedFun === "function") return "Error: not exported function was exported"
|
||||
|
||||
if (typeof lib.SomeClass !== "function") return "Error: exported nested class was not exported"
|
||||
if (typeof lib.ExcludedSomeClass === "function") return "Error: not exported nested class was exported"
|
||||
|
||||
if (lib.Companion.baz() !== "BAZ") return "Error: exported companion function was not exported"
|
||||
if (typeof lib.Companion.excludedFun === "function") return "Error: not exported companion function was exported"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user