Kay, how do I know when to use TypeScript

When and when not to use TSX

What the hell is even typescript?

Here are a few one-liners that I could come up or find that do a good job of explaining typescript in one sentence:

  • “Typescript is JavaScript for people who hate JavaScript”
  • “Typescript is just JavaScript, but with extra syntax (like java, c, or c++)”
  • “Typescript is a superset of JavaScript which strengthens JavaScript by sitting on top of it and adding an extra build step”
  • “Typescript is just JavaScript with types.”

When should you not use it?

See since Typescript is just JavaScript, but with extra syntax, it’s gonna occupy more lines of code, and it’s by default gonna take you more time in building because you’re kind of installing those safety checks for the future. So here are some use cases when you should steer away from it:

  1. If you want rapid prototyping and wanna get your MVP in the market FAST or are under a time constraint or a tight deadline, this may cause unnecessary delay. Use JavaScript in that case.
  2. If it’s a small project, the complexity + configuration + additional build steps = not good for small projects. So for small apps sure, use untyped code.
  3. If it’s one guy or a very small team project, you can use JavaScript.
  4. If you want less configuration, fewer false errors, faster builds, fewer compatibility issues when using 3rd-party stuff, and smaller payloads use JavaScript.

When should you use it?

  1. Typescript = fewer bugs and runtime errors.
  2. Large project = Use Typescript.
  3. Team size > 3 people = Use Typescript.
  4. If you don’t wanna end up writing documentation for your JavaScript, use Typescript. It also gives the code more structure, makes it self-documenting, and more readable, and speeds up debugging and refactoring.
  5. For apps that must be consistent through time and different team members, untyped code is your worst enemy, use Typescript.
  6. In the long run, it will save us a lot of time because a new developer will need a lot less time to understand the codebase.

My Unsolicited Opinion.

In 90% of cases, I’d recommend don’t waste time choosing this language or that language. Just pick one and stick to it. What matters more is getting the product out in the market fast and getting that juicy user feedback about your product and iterating upon it quickly.

If you’re a developer reading this and thinking if you should learn it or not, then I’d say:

“If the only tool you have is a hammer, all problems will look like nails”

And it’s always nice to have more tools in your toolbox. You never know which one might come handy to satisfy your customers.

Subscribe to Kay's Logs

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe