On NPM – the world’s largest software registry – TypeScript has over 19 million weekly downloads and is rocketing up its rankings in terms of the number of searches for the language.
TypeScript is a combination of tooling and optional, removable types, which aims to improve developer productivity. It also offers a better experience when writing code thanks to advanced autocompletion, navigation, and refactoring tools, without which large-scale refactorings can be risky.
It’s very JS-like
So why use TypeScript?
- Fewer compile-time errors: TypeScript won’t forget to check if a value is null, even if you did.
- Safe refactoring: Typescript shows you where you need to update so you don’t need to manually track your variables all over the code.
- Efficient autocomplete: This reduces coding errors as it minimizes the number of characters one has to manually type in.
- Reuse of code through inheritance: TypeScript supports the inheritance concept. If components have similar code, It is easy to extend a class and reuse the code.
- Flexibility through polymorphism: TypeScript supports polymorphism through function overloading and overriding, and project decoupling (separating projects into groups).
There are two, but they are so minor you may not even notice them! The first is that the compiler adds an extra step during development, which may slow things down. However, the compiler works fast and so there is minimal time wasted – and since compilation flags errors before deployment, it can even save time.
The second is that creating types and interfaces may also take time for the developer. However, it will save time at a later stage, when other developers are trying to read and understand the codebase.