Platform and version requirements: JS (1.1)

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:

external abstract class JQuery() {
    // some declarations here

external fun JQuery(element: Element): JQuery

See Also


© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.