HaxeFoundation / haxe.org-comments

Repository to collect comments of our haxe.org websites
2 stars 2 forks source link

[haxe.org/manual] Externs #12

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Externs - Haxe - The Cross-platform Toolkit

Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.

https://haxe.org/manual/lf-externs.html

elsassph commented 5 years ago

When creating externs you may hit problems with reserved keywords (https://haxe.org/manual/expression.html), in which case you can use the @:native meta:

extern class A {
    @:native('default') var default_: String;
    ...
}

extern interface B {
    @:native('class') var clazz: Dynamic;
    ...
}

var a: A;
a.default_ = 'x'; // will be generated as `a.default = "x"`

This @:native meta is only supported on classes and interfaces declarations, but not typedefs; most of the time interfaces can be used interchangeably to represent extern JSON objects.