With the help of the type system, during development your code is analysed continuously, looking for possible errors and or bugs. If it finds one, then you are noticed inside the code editor with a message of the error and a provided fix. And all of this happens without the need to execute the code.
TypeScript compiler analyses code by using type annotations. Type annotations let you define the type of variable, input or output for the function or method. For example, you can annotate the type of the function to be a String or some variable to be the type of a Boolean. And once you annotate, it tells the compiler that only this specific type is allowed to use. If the compiler detects a different type used on the identifier, it throws an error. In other words, you are describing the information that is going through your code.
Top comments (0)