W3cubDocs

/Kotlin

JsNonModule

Platform and version requirements: JS (1.1)
@Target([AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE]) annotation class JsNonModule

Denotes an external declaration that can be used without module system.

By default, an external declaration is available regardless your target module system. However, by applying JsModule annotation you can make a declaration unavailable to plain module system. Some JavaScript libraries are distributed both as a standalone downloadable piece of JavaScript and as a module available as an npm package. To tell the Kotlin compiler to accept both cases, you can augment JsModule with the @JsNonModule annotation.

For example:

@JsModule("jquery")
@JsNonModule
@JsName("$")
external abstract class JQuery() {
    // some declarations here
}

@JsModule("jquery")
@JsNonModule
@JsName("$")
external fun JQuery(element: Element): JQuery

See Also

JsModule

Constructors

Platform and version requirements: JS (1.1)

<init>

Denotes an external declaration that can be used without module system.

JsNonModule()

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/-js-non-module/index.html