Zero-cost bindings to tagged JS-objects

(moving this to its own thread)

I think what’s outlined in this issue would be really really valuable for ReScript: [Feature request] zero-cost binding to tagged JS objects · Issue #5207 · rescript-lang/rescript-compiler · GitHub

It’d mean one could seamlessly move between JS/TS and ReScript for variant-heavy code, such as ASTs (GraphQL, Babel, markdown and HTML-parsers etc, even TypeScript itself comes to mind). This in itself is very attractive as one part where ReScript shines is working with AST-like data, thanks to proper pattern matching etc.

@Hongbo, in theory, do you think the work you’ve done with @obj simplifies working on something like what’s outlined in the issue?

11 Likes

Now that I understand the feature properly there is another library that will benefit from this wich is jscodemod. It is very useful to run complex code modifications on JS code

Hi @zth, sorry for the late reply.

I agree this is nice for interop with typescript style data structure, however, this would require aggressive work on multiple phases in the compiler. I don’t think currently I have time to work on it or even review the changes.

1 Like

@Hongbo thank you for the reply. Fingers crossed this might be considered in the future then :crossed_fingers:

4 Likes