HaxeFoundation / HaxeFoundation/haxe

[js] Metadata is set after __init__

Open
#9,671 1 comment 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
@foo class Test {
static function __init__()
trace(haxe.rtti.Meta.getType(Test)); // {}
static function main() {
trace("Haxe is great!");
}
}
```

That's because the generated JavaScript will look like this:

```js
console.log("tests/Test.hx:3:",haxe_rtti_Meta.getType(Test));
Test.__meta__ = { obj : { foo : null}};
```

Since runtime metadata may online contain constants, it should be safe to initialize all of it before all `__init__` calls.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.