It sounds like a bug so I've just reported it ->
https://github.com/HaxeFoundation/haxe/issues/3229
Reason of why this is happening:
Haxe "class object" is compiled to a Function object in JS. For example the Main class in your example: "var Main = function() { };"
In JS, Function has an instance method "
length". To avoid causing conflict, haxe renamed static length method to "$length".
Workaround is to use __js__ magic with inline:
inline static function length():Int return untyped __js__("Test.length()");
Hope it helps.
Best,
Andy