There are two main goals of TypeScript:
Provide an optional type system for JavaScript and provide planned features from future JavaScript editions to current JavaScript engines.
The desire for these goals is motivated below.
You might be wondering “Why add types to JavaScript?”
Types have proven ability to enhance code quality and understandability. Large teams (Google, Microsoft, Facebook) have continually arrived at this conclusion. Specifically:Types increase your agility when doing refactoring. It’s better for the compiler to catch errors than to have things fail at runtime.
TypeScript is very particular about keeping the barrier to entry as low as possible. JavaScript is TypeScript. TypeScript provides compile time type safety for your JavaScript code. This is no surprise given its name. The great thing is that the types are completely optional. Your JavaScript code .Js file can be renamed to a .ts file and TypeScript will still give you back valid .Js equivalent to the original JavaScript file. TypeScript is intentionally and strictly a superset of JavaScript with optional Type checking.
TypeScript will try to infer as much of the type information as it can in order to give you type safety with minimal cost of productivity during code developer.