DEV Community

Phan Hieu Nguyen
Phan Hieu Nguyen

Posted on

And done! - Part3 of OSD0.4

Let's start with the technical first, because my professor wants me to and it's dry ZzZ. But who am I to tell, I'm not the expert on Gatsby or NextJS or anything really. So here is the technical stuff about them, enjoyy!
My real work is on migration between them. The first big step was converting JS/JSX files to TS/TSX files, because they want to switch to TypeScript. And I agree, TypeScript is safer, and you can choose to be unsafe and write exactly in JavaScript way without problem. In this step, most of my work was writing interfaces and classes with data members with type-check. So later on, I can have safer type-check when use the variables of those types. And of course the process is never perfect. There are always some variables you have no clue what types the can be. The more difficult problem was converting JSX variable types check to TSX because they are not always the same. Some of them are deprecated, some of them don't have documentations support. And lastly I have to be careful about dependencies. Some of JS version don't have @type equivalent (90% do), and I really don't want to install random stuff on package.json just to getaway with compilation errors.
The second big step was converting Gatsby's libraries, functions to NextJS's equivalents. There are official documentation on how to migrate from Gatsby to NextJS, so it should be easy right? Ya, but it's only for simple components which were used the way they were documented. How many of us, and how much of the code were actually used in the way in documentation? As any project got bigger and more complex, the code will get more and more different from documentation (in my experience, I could be wrong). So it just take a lot of time to find the right way doing this. I guess that's why we have this job lol.

Top comments (0)