rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create Bindings from typescript definitions

searleser97 opened this issue · comments

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).

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.

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.

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

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.

For that direction, there's a separate tool that's making rapid progress: ocsigen/ts2ocaml#32.

this looks good

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

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