rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.
https://rescript-lang.org/docs/gentype/latest/introduction
MIT License
758 stars 44 forks source link

Create Bindings from typescript definitions #574

Closed searleser97 closed 10 months ago

searleser97 commented 3 years ago

It would be amazing if this library also works the other way around. Right now it can create typescript definitions from rescript code but not the other way around. A feature like this one will allow us to quickly reuse libraries with typescript bindings (there are a lot of them).

alarbada commented 3 years ago

Related work would be the ts2fable project, but I don't know how hard would be to implement that.

In my experience with it was not that great, it needed a lot of tweaking with the transpiled result. I don't know how well do ts idioms translate to rescript though.

kevinbarabash commented 2 years ago

This would also be helpful when converting large projects from TypeScript to ReScript. An interesting edge case is creating binding from TypeScript code that itself uses generated bindings from ReScript code. In these situations, we'd GenType to recognize this and use the original ReScript types in the generated bindings instead of generating new ReScript types from the TypeScript types.

kevinbarabash commented 2 years ago

I found ReasonablyTyped which looks promising. It doesn't appear to be maintained anymore, but it could serve as a good starting point.

kevinbarabash commented 2 years ago

I didn't realize this project was written in OCaml and not BuckleScript. The approach ReasonablyTyped takes won't work since it interfaces directly with TypeScript's node API. It probably makes sense to have the reverse direction be a separate tool.

cristianoc commented 2 years ago

For that direction, there's a separate tool that's making rapid progress: https://github.com/ocsigen/ts2ocaml/pull/32.

utenma commented 2 years ago

this looks good

listepo commented 1 year ago

Hey @cristianoc I think you need to create your own alternative for DefinitelyTyped with https://github.com/ocsigen/ts2ocaml/pull/32. What do you think? I think this is the main reason why it is difficult to compete with the Typescript

ryyppy commented 10 months ago

This repository is being archived. If you feel like the issue still relevant, please re-create it in the compiler repo. Thanks!