elsassph / hxtsdgen

TypeScript declaration file generator for Haxe JavaScript output target
65 stars 12 forks source link

Declaration for function param types not being generated #27

Open fullofcaffeine opened 5 years ago

fullofcaffeine commented 5 years ago

Hey Philippe,

Thank you for the latest additions to this lib!

I've tried it out but I'm having some issues. For some reason it's not generating the declaration for the param types here: https://github.com/haxe-boilerplate/pwa-ts-haxe-boilerplate-take-2/blob/master/src/ts/server/hx.d.ts#L28.

The correspondent Haxe source is: https://github.com/haxe-boilerplate/pwa-ts-haxe-boilerplate-take-2/blob/master/src/hx/server/TinkAPI.hx#L44.

Do you know why? The type is being exposed.

Thanks in advance!

Do you know why?

fullofcaffeine commented 5 years ago

I managed to find a workaround for now, which at least makes the TS compiler happy:

Source: https://github.com/haxe-boilerplate/pwa-ts-haxe-boilerplate-take-2/blob/workaround/src/hx/server/TinkAPI.hx#L18

Generated declaration file: https://github.com/haxe-boilerplate/pwa-ts-haxe-boilerplate-take-2/blob/workaround/src/ts/server/hx.d.ts

I would love to avoid defining those dummy classes just for the sake of a correct declaration file, though.

elsassph commented 5 years ago

Hmm how are those types defined? in hxnodejs?

fullofcaffeine commented 5 years ago

Yes

elsassph commented 5 years ago

Oh! Right we dont support yet @:jsRequire classes... https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/http/IncomingMessage.hx

Note that you appeased typing gods, but it's as good as having replaced it by Dynamic.

fullofcaffeine commented 5 years ago

Note that you appeased typing gods, but it's as good as having replaced it by Dynamic.

Yes, I'm aware. In any event, I think the best approach now is to create some kind of adapter class that exposes simpler / more specific types to TS instead of trying to expose these directly. At least until hxtsdgen handles more complex cases like this.