Gentype: Typescript to Rescript types

I’m very new to reasonml/rescript community, What I know genType generates TS/flow types from rescript component while working in existing Typescript/flow codebase. Is there any other way around like I’m working on existing rescript codebase, does it generates bindings for rescript from typescript component/library types?

Can someone enlighten me?

1 Like

Welcome to the ReScript forum!

This has been discussed before here: Possible to import typescript packages into reason?

I think we won’t ever be able to fully automate this task, but a semi-automated way is often good enough. The most promising tool out there is ts2ocaml, which has an open PR for ReScript bindings. Still a lot of work open though, and I guess they are also waiting for some advances in the compiler repository.

Maybe the author @cannorin can shed some more light on its state.

3 Likes

@fham Thanks for answering

It’s about 70% done, as it can generate something that looks like a valid ReScript code, and it’s time to generate a lot of bindings and feed them to the compiler to see what happens.

Unfortunately the compiler needs some work to compile the generated codes: https://github.com/rescript-lang/rescript-compiler/pull/5364 and https://github.com/rescript-lang/rescript-compiler/issues/5368.

(also https://github.com/rescript-lang/rescript-compiler/pull/5350 is very nice to have, as I would have to create my own bigint without it)

I’m currently waiting for the response to the PR and the issue. Once they are resolved, I can start the mass testing.

8 Likes

Thank you for working on this!

1 Like

The first paragraph of GenType claims that it uses types from typescript at: Introduction | ReScript GenType

I take that to mean that I don’t have to do anything with regard to types when importing typescript packages.