Open clarkjones opened 4 years ago
Hey @clarkjones, you’re right and unfortunately haxe does not have a way to solve this yet! There is a proposal to support @:native
on typedef fields so this may work in the near future
More discussion on the haxe repo: https://github.com/HaxeFoundation/haxe/issues/5105
thanks for the info. Creating an extern interface is not an option in dts2hx?
In this case an interface might do but not in the general case because we need the structure unification rules to apply, so a typedef gives you the most typescript-like behavior here
Just a note for future self, I think we can solve this by wrapping the typedefs with abstracts – not perfect but it will help as an interim before future compile changes fully resolve the issue
typedef StructureTypedef = {
@:native('continue')
function continue_(?overrides:Overrides):js.lib.Promise<Void>;
}
abstract Structure(StructureTypedef) {
@:from static function fromTypedef(obj: StructureTypedef) {
// apply @:native fields
}
}
when running dts2hx on puppeteer it generates a Request typedef that contains the following.
From what I can tell this only works for classes & interfaces