haxiomic / dts2hx

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

extends tyep error. #85

Closed sonygod closed 3 years ago

sonygod commented 3 years ago

cocoscreator.d.ts

static loadRes(url: string, type: typeof cc.Asset): void; to haxe

static function loadRes(url:String, type:{ var prototype : Asset;});

and

@:native("sp.SkeletonData") extern class SkeletonData extends global.cc.Asset 

when type

Loader.loadRes('loadSpine/alien-ess',SkeletonData);

will throw this compile error

for argument type:{prototype:Asset}

error: global.sp.SkeletonData should be global.cc.Asset
have: { prototype: global.sp.SkeletonData }
want: { prototype: global.cc.Asset }
For function argument 'type'diagnostics(2)
haxiomic commented 3 years ago

hmm, the type looks as correct as we can make it but the error seems to be more about haxe's more restrictive type system. I don't think there's much we can do here. Bet solution is to use cast here: Loader.loadRes('loadSpine/alien-ess', cast SkeletonData);