benmerckx / genes

Generates split ES6 modules and Typescript definitions from Haxe modules.
43 stars 8 forks source link

Default value in function arguments #54

Closed kevinresol closed 2 years ago

kevinresol commented 2 years ago

The following should all trace true because haxe generates null-checks inside the function body.

But genes puts the default value on the function signature thus breaks the foo(null) case

class Main {
    static function main() {
      trace(foo(1) == 1);
      trace(foo() == 42);
      trace(foo(null) == 42); // false with genes because null is returned
    }

    static function foo(v = 42)
      return v;
}