What we find interesting though, is that the two are often compared as if they were mutually exclusive languages, and the question is usually 'which is better'. This is interesting, because this shouldn't be the case all.
What is TypeScript
- It's a compiled language
- It has optional static type checking
- Enumerated types
That's not an exhaustive list, but it gives an idea as to why TypeScript is compelling, particularly if you have a background in similar languages like C# etc.
Compiled To JS
Type Checking Is Compile Time Only
TypeScript offers static type checking, which is great if you're more used to working with strictly-typed languages.
When To Use TypeScript
When you are building:
- Large applications
- Private APIs
TypeScript is a great fit for these because writing interfaces, and specifying types is really helpful when you have literally hundreds of files and even more functions.
If you do use the wrong type somewhere in your code, compilation will fail which means catching bugs way before they hit production.
- Small to medium applications
- Building Public APIs
- Website code
- Leveraging the power of dynamic typing