I started using genType with the aim of easing interop with TypeScript. Here’s what I understood about genType’s purpose based on the docs and the GitHub readme:
- Auto-generate JS-land types from ReScript types
- Auto-generate ReScript types from JS-land types
- Auto-generate JS-land bindings for ReScript values
- Auto-generate ReScript bindings for JS-land values
What I’ve found in practice is that genType can do the following:
- Auto-generate JS-land types from a subset of ReScript types (for example, no support for dictionaries). This is genuinely awesome and super useful.
- Stub JS-land types in Reason with an “opaque” type, meaning that the generated type doesn’t retain the data structure of the JS-land type. Not sure what this achieves.
Additionally, it appears that you can import/export values using genType, but I don’t see the advantage of doing it with genType vs. the “normal” way. You still end up writing bindings by hand.
So by my count, genType is 1 for 4 in terms of its usefulness. Its ability to generate opaque types in ReScript doesn’t seem very useful to me and I don’t understand what’s different about genType’s process for importing/exporting values, other than some cosmetic differences (e.g., which decorators you use).
Can someone enlighten me? What am I missing?