Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strategy for moving from TypeScript to ReScript #1

Closed
Voles opened this issue Jan 15, 2022 · 1 comment
Closed

Strategy for moving from TypeScript to ReScript #1

Voles opened this issue Jan 15, 2022 · 1 comment

Comments

@Voles
Copy link

Voles commented Jan 15, 2022

Hi @greyblake 馃憢

First of all, thanks for sharing your work. I've read your blog post about the conversion and found it really insightful.

One thing I'm struggling with at the moment is how to convert an existing TypesScript project to ReScript without a big-bang.

I'm aware of %%raw() to gradually move vanilla JS code to ReScript. But I'm missing how to do the same for TypeScript code.
Did you migrate you project gradually? Of did you migrate all the code in one go?

Many thanks!

@greyblake
Copy link
Owner

@Voles Hi,

thanks for contracting me.
Yes, I migrated my project gradually, in fact, file by file.

The easiest place to start is to find a functions / components, that do not depend on anything else in your codebase. You rewrite them in ReScript and use @gentType (https://rescript-lang.org/docs/gentype/latest/introduction) to generate .tsx files that you can use in the rest of TypeScript codebase.

Sometimes, there are situations, when you'll have writing ReScript bindings to you own TS code. This was a little bit annoying for me, known that at the end I will remove those bindings, but it was a necessary step to rewrite gradually.

I recommend your checking this tutorial: https://rescript-lang.org/docs/manual/latest/installation#integrate-into-an-existing-js-project

I also have to warn you, that probably rewriting for the sake of rewriting (like I did) is not the best time/effort investment. You'd rather just start using ReScript for new features, and rewrite old code only when you feel like doing that :)

If you have more questions, you can ask them on the Forum: https://forum.rescript-lang.org/
Or StackOverflow.

You can also reach me on Twitter (https://twitter.com/greyblake) if I can help.
I got also a lot of help from https://twitter.com/tsnobip and https://twitter.com/yawaramin when I was rewriting.

Good like to you! =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants