node-bindgen icon indicating copy to clipboard operation
node-bindgen copied to clipboard

Feature Request: Generate d.ts definitions

Open timfish opened this issue 5 years ago • 2 comments

It would be great to also generate .d.ts type definitions so that we'd get TypeScript compile time checking against the native library too.

Thank you for this library, it's great!

timfish avatar Jun 23 '20 11:06 timfish

You are welcome. Yes, it seems like typescript integration will be valuable

sehz avatar Jun 23 '20 19:06 sehz

This task is a bit of work (not a bad thing). I think there's a couple main things about this that are nontrivial but we will want:

  • configuring the output directory (and whatever things the generations will in the future support). The setup for generated definiton output should be similar to cbindgen and rust-bindgen.
  • How do we find the things to generate the typescript bindings for? We will probably want to do something like how cbindgen parses the entire crate, module, and submodules looking for things that are prefixed with extern but in our case, we'd need to look for the node_bindgen proc macro (I think this can be done) in our case.
  • Generating the docstring in the typescript shouldn't be too hard once we get the ladder of these.
  • Maybe we'd want module support for things? In the fluvio-client-node project for example, maybe we'd want consumer.rs to have a consumer.d.ts and for producer.rs to have a producer.d.ts or something. This would obviously be a low priority feature.

simlay avatar Dec 30 '20 00:12 simlay