haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
131 stars 8 forks source link

Missed type in phaser example #50

Open RblSb opened 3 years ago

RblSb commented 3 years ago
    static function create(data: Dynamic) {
        var scene: Scene = js.Lib.nativeThis;
        scene.add.tween(); // add this

Should be: tween(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.Tween; But generated as: public function tween(config:Dynamic):global.phaser.tweens.Tween

haxiomic commented 3 years ago

The problem here is the type has | object which makes the effective type any object

I can tweak it to generate AnyOf<TweenBuilderConfig, Dynamic> but I'm not sure haxe will handle it better. It may be better user documentation tho so I'll keep it on the roadmap. TypeScript does seem to handle this well however because you get autocomplete for TweenBuilderConfig (even if any object will pass)

For now, manually removing the | object should remove the Dynamic

RblSb commented 3 years ago

I think type | object is EitherType<type, object>, doesn't? And probably Haxe should at least show completion hints for first type in Either (just like it works for overloads).

haxiomic commented 3 years ago

Yeah, I think the problem I had was that haxe doesn't show completion hints here, tho maybe it will in future versions. In any case in the next iteration of dts2hx I'll make it generate EitherType<TweenBuilderConfig, Dynamic> (which is the same as AnyOf2 in dts2hx)