DEV Community

Discussion on: TypeScript is the Only Programming Language you Need to Learn. One language to rule them all!

Collapse
 
ryannerd profile image
Ryan Jentzsch

Overall TS brings some sanity to an insane language. Mostly helping to catching bugs before running being the primary benefit with the secondary being making it easier to reason about your interfaces, for example with function foo(s: string, n: number): boolean you know the expected arguments are a string and a number with the return type of boolean. All major IDEs leverage TS providing type hints.

There are some disadvantages:

  1. Upfront time. TS will bitch and moan at everything it thinks isn't type safe. Forcing you to include type guards and other reassurances to TS that the variable it's complaining about really is expected to be a number prop.onClick(id as number)
  2. There are some situations where TS is overtly difficult to implement for example 3rd party data that you have no control over the structure and types.
  3. To overcome #2 you can write generics and type overrides but once again this falls into the #1 disadvantage.
  4. TS error messages are sometimes difficult to understand and even a trip to SO can still leave you scratching your head.
  5. If your code is littered with @ts-ignore there's a bigger problem than TS going on.
Collapse
 
rammina profile image
Rammina • Edited

I agree with your points. We have a lot of overlaps when it comes to opinions about its downsides.

Number 4 is so awful and relatable. Even a popular library like redux-form has really bad issues with Typescript, and people over at Github and SO are struggling to find stopgap solutions to errors.