But to use it in all of my projects, I’ll have to stop myself there because I might waste unnecessary time in adding one to the project. Been there, done that.
Want to know when not to use TypeScript? Let us first define what TypeScript is.
What is TypeScript?
Microsoft has designed TypeScript mainly with large applications in mind such as enterprise applications with over 500 users or more. TypeScript can also be used in back-end apps such as NodeJS for strongly-typed language.
Now let us know when not to use TypeScript at all. Here are some use-cases which you might reconsider the use of TypeScript:
When building small or prototypes
Let us compare the two code when programming some features:
const myFunction = (x, y) => x * y;
const myFunction = <T>(x: T, y: T) => x * y;
Adding TypeScript code in the project requires us to declare types such as this example and you might hate doing that during the prototyping phase.
Notice here that the ones using TypeScript are noisier since we need to declare types to get the job done. Although one could argue that the one using TypeScript is verbose and easy to debug when things get bad for this functionality but that depends on how you or your developer will make use of the type system. Your developer may just simply toss in a lot of
any as type in the function so it may not be that helpful at all.
This use-case is debatable though since one might argue that it will save us a lot of time by adding type-checking ahead of time and prevent bugs that might give you some headaches as you build your prototype. It’s true that static types may save you a lot of time in the long run, but not when you’re building your own prototype that might not get to the next stage nor profit it deserves at this point.
When it’s not giving any value nor results you expected
TypeScript is only good when it delivers the results it promises but bad if it fails to deliver. You must know first the reason why you want to use and apply it in your projects in the first place before actually delving deeper to use it.
For example, identify first the type of app that you are about to build. Is it a prototype? An enterprise? An app that is only focused on User Interactions or Animations? Or an app filled with complex computations and formulas?
You need to evaluate the effectiveness and values TypeScript can offer you first then use it so that you can get the most out of it.
When your developers are inexperienced and not willing to adapt in it
You can carefully evaluate and observe how experienced your developers are in using TypeScript. You can also gauge how much learning curve time do they need when they’re going to use it. If you have a bunch of developers who don’t know TypeScript, you might have to back out in enforcing this technology to them unless there’s ROI in doing so.
We cannot always enforce our team to adapt to TypeScript unless there’s a compelling reason to do so and depending on the type of projects your team handles. This also depends on the type of skillsets they have before you enforce it to them. Do they have OOP backgrounds such as C# and Java? If not, this will only cause harm than good.
Lastly, I think it’s worth asking your team whether they’re willing to adapt and use this technology. It could be selfish on your part to just enforce it without gauging your team’s skillsets, proper justification, and analysis of the problem you’re solving.
The need for TypeScript needs to be further analyzed before we delve deeper and use it in your projects with your team and they will thank you for that!
When you’re using it because of “hype”
Last but not least, if you’re just using TypeScript for the sake of “hype”, I think you’re in the wrong direction. For practice and getting the hang of TypeScript, there is no problem in using it. But to use it in production apps just because of “hype” is unreasonable and not a good indicator that this will add value.
I’ve been in that situation wherein I jump back and forth in new technologies that I come across. But as I grew more mature as a Software Engineer, I realized that it’s pointless to delve into new technologies or hypes if it fails to provide the value that we offer.
I hope I helped you decide when or when not to use TypeScript in your projects based on the use-cases that I outlined above.