TypeScript is an open source programming language created by Microsoft. It is a superset of JavaScript, meaning it contains all of the functionality of JavaScript plus additional features. It is a strongly-typed, object-oriented, compiled language. Because it’s a superset, any program written in JavaScript will also run in TypeScript. It was created to allow for optional static type checking, which is valuable for developing large-scale applications. TypeScript is used to help catch mistakes early through a type system and make JavaScript development more efficient.
TypeScript uses static type checking, meaning that variables can be given a type when they are declared. The programming language will check types when it’s time to compile and throw an error if the variable is given a value of a different type. If there is an error, it does not prevent the code from executing; the code will still be compiled. Static type checking is optional, so if no type is given, the type will be set to any by default.
JavaScript, in contrast, is dynamically typed. Variables can be reassigned or coerced into a value of a different type without warning, resulting in bugs that are easy to overlook if an application is large.