If you find the arguments for type systems persuasive in general, then you'll be happy with TypeScript.
The merits of typed vs. untyped languages have been debated for decades. Arguments for static types include:
- Safety: type systems allow many errors to be caught early, without running the code. TypeScript can be configured to allow fewer programming errors
- Readability: explicit types make code easier for humans to understand. As Fred Brooks wrote, "Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious."
- Tooling: type systems make code easier for computers to understand. This allows tools like IDEs and linters to be more powerful.
- Performance: type systems make code run faster by reducing the need for runtime type checking.
Because TypeScript's output is independent of its types, TypeScript has no impact on performance. The argument for using TypeScript rests on the other three advantages.
Arguments against type systems include:
- Added complexity: type systems can be more complex than the language runtime that they describe. Higher order functions can be easy to implement correctly but difficult to type. Dealing with type definitions creates additional barriers to using external libraries.
- Added verbosity: type annotations can add boilerplate to your code, making the underlying logic harder to follow.
- Slower iteration: by introducing a build step, TypeScript slows down the edit/save/reload cycle.
- Incompleteness: A type system cannot be both sound and complete. There are correct programs which TypeScript does not allow. And programs which TypeScript accepts can still contain bugs. A type system doesn't alleviate the need for testing. If you use TypeScript, you may have to wait longer to use new ECMAScript language features.
TypeScript offers some ways to address all of these issues:
- Added complexity. If typing part of a program is too difficult, TypeScript can be largely disabled using an opaque
any type. The same is true for external modules.
- Added verbosity. This can partially be addressed through type aliases and TypeScript's ability to infer types. Writing clear code is as much an art as a science: remove too many type annotations and the code may no longer be clear to human readers.
- Slower iteration: A build step is relatively common in modern JS development and TypeScript already integrates with most build tools. And if TypeScript catches an error early, it can save you an entire iteration cycle!