Chase Baker
- Software Engineer
I recently wrote a blog on which state management to go with when starting a React project. Another question is “Which do I choose JavaScript or TypeScript?” So, I decided to write another short blog about the pros and cons of both and what I ended up going with.
I’ll just get right into it!
React with JavaScript
React was originally intended to be used with JavaScript so some purists may want to keep it that way. If you want to use the one that is more widely used than ReactJs would be the choice. Also with it being the most common it will be easier to find more examples online for it.
Pros:
- Less Code
- Arguably shorter compile time
- Reacts standard documentation is JS oriented
- Massive support for JavaScript in general
- Solid Performance with JavaScript
Cons:
- Higher Chance of Production Bugs
- Not as simple to read/Messy
- Creating Standards for developers can be more challenging
- Comes with issues the JavaScript already has
- No Intellisense
React with TypeScript
This is a relatively new way of building React apps but is gaining ground. TypeScript in general is becoming more and more popular for front-end web development mostly due to its readability and type checking.
Pros:
- Type checking
- Cleaner code
- Arguably less bugs
- Less unit tests
- Simpler documentation
Cons:
- Longer compile time
- More code
- Type checking can be annoying hard to manage
- Less libraries with type support (Has been getting better with time)
- Support is great but not as much as JavaScript
Conclusion:
After all my reading and researching it really turned into an argument of JavaScript vs. TypeScript instead of using React with one or the other. The support seems to be there for both, clearly there is more support and/or uses of ReactJS found online. While both have their advantages and disadvantages my recommendation would be TypeScript.
I think the benefits outweigh the risks, TypeScript has a massive following and seems to be the way the world of front-end development is going. With TypeScript it is easier to catch bugs that could have caused production errors reported by users which is the last thing we as developers want. The code is cleaner and will be easier to scale or change as the project does. I also think newer developers (or new to the team) can adjust to it easily because they will need to follow TypeScripts strict typing laid out by the more seasoned developers.
Well that’s my opinion on the topic and I hope that this blog was helpful in some way. Thanks for reading!
Below are a few of the articles I used to research the topic
For TypeScript:
Advantages of using React with TypeScript
Against TypeScript:
I couldn’t find a ton of reading on this exactly, most of the views I found against it were from stack overflow and/or reddit threads. Here is one article I found against TypeScript.
Don’t use TypeScript for your next project
Helpful Video that simply talks about both React with JavaScript and TypeScript.