Package-level declarations

Functions and other APIs specific to the JavaScript platform.

Functions and other APIs specific to the JavaScript platform.

Types

Link copied to clipboard
external interface Console

Exposes the console API to Kotlin.

Link copied to clipboard
external class Date

Exposes the Date API to Kotlin.

Link copied to clipboard
annotation class ExperimentalJsExport

Marks experimental JS export annotations.

Since Kotlin 1.4
Link copied to clipboard
external interface JsClass<T : Any>

Represents the constructor of a class. Instances of JsClass can be passed to JavaScript APIs that expect a constructor reference.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE])
expect annotation class JsExport

Exports top-level declaration on JS platform.

Since Kotlin 1.4
@ExperimentalJsExport
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE])
actual annotation class JsExport

Exports top-level declaration on JS platform.

Since Kotlin 1.3
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE])
annotation class JsModule(val import: String)

Denotes an external declaration that must be imported from native JavaScript library.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
expect annotation class JsName(val name: String)

Gives a declaration (a function, a property or a class) specific name in JavaScript.

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
actual annotation class JsName(val name: String)

Gives a declaration (a function, a property or a class) specific name in JavaScript.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE])
annotation class JsNonModule

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

Link copied to clipboard
external object JSON

Exposes the JavaScript JSON object to Kotlin.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FILE])
annotation class JsQualifier(val value: String)

Adds prefix to external declarations in a source file.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeGetter
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeInvoke
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeSetter
Link copied to clipboard
open external class Promise<out T>(executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit)

Exposes the JavaScript Promise object to Kotlin.

Link copied to clipboard
external class RegExp(pattern: String, flags: String? = definedExternally)

Exposes the JavaScript RegExp object to Kotlin.

Link copied to clipboard
external interface RegExpMatch

Represents the return value of RegExp.exec.

Functions

Link copied to clipboard
fun Json.add(other: Json): Json

Adds key-value pairs from other to this. Returns the original receiver.

Link copied to clipboard
inline fun RegExpMatch.asArray(): Array<out String?>

Converts the result of RegExp.exec to an array where the first element contains the entire matched text and each subsequent element is the text matched by each capturing parenthesis.

Link copied to clipboard
inline fun Any?.asDynamic(): dynamic

Reinterprets this value as a value of the /docs/reference/dynamic-type.html.

Link copied to clipboard
Link copied to clipboard
external fun eval(expr: String): dynamic

Exposes the JavaScript eval function to Kotlin.

Link copied to clipboard
inline operator fun RegExpMatch.get(index: Int): String?

Returns the entire text matched by RegExp.exec if the index parameter is 0, or the text matched by the capturing parenthesis at the given index.

Link copied to clipboard
operator fun dynamic.iterator(): Iterator<dynamic>

Allows to iterate this dynamic object in the following cases:

Link copied to clipboard
external fun js(code: String): dynamic

Puts the given piece of a JavaScript code right into the calling function. The compiler replaces call to js(...) code with the string constant provided as a parameter.

Link copied to clipboard
fun json(vararg pairs: Pair<String, Any?>): Json

Returns a simple JavaScript object (as Json) using provided key-value pairs as names and values of its properties.

Link copied to clipboard
inline fun jsTypeOf(a: Any?): String

Function corresponding to JavaScript's typeof operator

Link copied to clipboard
external fun parseFloat(s: String, radix: Int = definedExternally): Double
Link copied to clipboard
external fun parseInt(s: String): Int
external fun parseInt(s: String, radix: Int = definedExternally): Int
Link copied to clipboard

Resets the regular expression so that subsequent RegExp.test and RegExp.exec calls will match starting with the beginning of the input string.

Link copied to clipboard
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?): Promise<S>
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?, noinline onRejected: (Throwable) -> S?): Promise<S>
Link copied to clipboard
inline fun <T> dynamic.unsafeCast(): T

Reinterprets this dynamic value as a value of the specified type T without any actual type checking.

inline fun <T> Any?.unsafeCast(): T

Reinterprets this value as a value of the specified type T without any actual type checking.

Properties

Link copied to clipboard
external val console: Console

Exposes the console API to Kotlin.

Link copied to clipboard
external val definedExternally: Nothing

The property that can be used as a placeholder for statements and values that are defined in JavaScript.

Link copied to clipboard
val <T : Any> KClass<T>.js: JsClass<T>

Obtains a constructor reference for the given KClass.

Link copied to clipboard
val <T : Any> JsClass<T>.kotlin: KClass<T>

Obtains a KClass instance for the given constructor reference.

Link copied to clipboard
external val noImpl: Nothing
Link copied to clipboard
external val undefined: Nothing?

Exposes the JavaScript undefined property to Kotlin.