What is TypeScript?
Fewer Errors in Runtime:
Say GoodBye to such errors with TypeScript.
Fact: You will have fewer surprising moments when viewing runtime errors.
Easy to Write and Maintain:
Abstraction can easily be expressed in Typescript. You can use the abstract keyword to define an abstract class that contains one or more abstract methods.
While this may look quite obvious, when you pass values to function which pass that value to another function, you quickly lose track of **simple** things like these which lead to a lot of debugging down the line.
Can I use dynamic typing using TypeScript though?
This defines a dictionary that takes any string as key and will take a string as its value. The only problem is that when you try to access the keys, you don’t know whether that particular dictionary has that key or not.
Or when all hope is lost, you can simply use the “any” type.
Fact: TypeScript is definitely a strict language, but it’s worth your time.
TypeScript generics provide a way to create reusable components that work with a variety of types. By using generics, you can write code that can work with a variety of types, rather than being tied to a specific type. This can make your code more flexible and easier to reuse in different contexts. Generics make code easier to read and understand, because it separates the essential logic and the minimal constraints required in types from the rest of the application code.
In other terms, Generics are to Types, what Types are to Variables.
To Scale Big Projects:
Hence, when it comes to implementing large-scale applications, TypeScript is a powerful type system where one can create types from other types. Moreover, it has excellent tooling support, including code completion, refactoring, and debugging support in many popular code editors.
Fact: Even Slack uses TypeScript
Popular and Active:
Fact: You will find a large community which will help you move ahead when you get stuck in TypeScript.
How to Change your Code from JS to TS?
Start small, add some typing to some of your code and use `"strict": false,` in the tsconfig.json of your project. And once you feel comfortable enough, set the strict flag to true.
Additionally, for code that you know has correct typing in that particular use case, you also might feel comfortable using @ts-ignore flag to disable type checking in the next line.