dts2hx icon indicating copy to clipboard operation
dts2hx copied to clipboard

Missed type in phaser example

Open RblSb opened this issue 5 years ago • 3 comments
trafficstars

	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

RblSb avatar Aug 28 '20 09:08 RblSb

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

haxiomic avatar Aug 28 '20 15:08 haxiomic

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).

RblSb avatar Aug 28 '20 19:08 RblSb

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)

haxiomic avatar Aug 31 '20 12:08 haxiomic