greyblake / from-typescript-to-rescript

Frontend of https://Inhyped.com written in TypeScript and rewritten in ReScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strategy for moving from TypeScript to ReScript

Voles opened this issue Β· comments

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!

@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! =)