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

Feature request: map to hxnodejs types #57

Closed ciscoheat closed 1 year ago

ciscoheat commented 3 years ago

When using your instructions in #54 the generation works fine, except for a few mishaps:

Browser.hx:

function process():node.child_process.ChildProcess;

Which is fixed by changing it to (using hxnodejs):

function process():js.node.child_process.ChildProcess;

ElementHandle.hx and others

@:overload(function(?options:BinaryScreenShotOptions):js.lib.Promise<global.Buffer> { })
@:overload(function(?options:ScreenshotOptions):js.lib.Promise<ts.AnyOf2<String, global.Buffer>> { })
function screenshot(?options:Base64ScreenShotOptions):js.lib.Promise<String>;

Where global.Buffer must be replaced with js.node.Buffer.

The rest works very well!

haxiomic commented 3 years ago

The externs should still work – dts2hx has also generated types in .haxelib/node, which are essentially an alternative to hxnodejs (try adding --library node in addition to --library puppeteer to make it work)

However I expect some users will want to use hxnodejs externs instead, so it's worth adding as a feature to dts2hx, I think I'll add under a new flag --hxnodejs

Mind if I change the title to "Feature request: map types to hxnodejs externs" to help me remember?

ciscoheat commented 3 years ago

Using hxnodejs was indeed the reason it didn't work, so an option for that would be great. No problem changing the title. :)

haxiomic commented 1 year ago

Feature added! (Sorry it took so long!) You can now add --hxnodejs and it'll map types where they exist to hxnodejs

ciscoheat commented 1 year ago

Thank you!