forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
JS compiler annotations
Vladimir Krivosheev edited this page Jun 4, 2013
·
9 revisions
Applicable to any. Recursive. Use it to declare stubs (existing API on JS side). If name specified, it will be used instead of declaration name.
public native fun kt_invoke(o:Any, m:String, args:Array<Any?>?):Unit = noImplApplicable to native function, native function parameter or native class. Not recursive.
All optional arguments (usage of named arguments is much better solution than options object) will be wrapped to object literal.
// JS API
chrome.windows.update(integer windowId, object updateInfo, optional function callback)// Kotlin API
optionsArg
public fun update(windowId:Int,
focused:Boolean? = null, drawAttention:Boolean? = null,
callback:((window:Window)->Unit)? = null)
// usage
chrome.windows.update(id, focused = true) {
// callback code
}// generated code
chrome.windows.update(id, {focused: true}, callback);Function parameter may be annotated too, in this case it can be not-optional argument (in complicated ambient function signature you can annotate only function parameters, to precise control).
Applicable to class or trait. Not recursive.
By default class properties is not enumerable, but you can use this annotation to make properties enumberable. It is useful for DTO.
public enumerable class Debuggee (public val tabId:Int) {
public fun toString():String = tabId.toString()
}