TypeScript is an open source language and is a superset of JS.
- offers additional features to js including static types.
- using types is completely optional
- compiles down to regular js
- can be used for FE js as well as BE with node.js
- includes most features from es6, es7 (classes, arrow function, etc)
- types from 3rd party libs can be added with type definitions
Dynamic vs Static typing
- Dynamically typed languages, the types are associated with run-time values and not named
explicitly in your code
ex) js, python, php, ruby
- Statically typed languages, you explicitly assign types to variables,
function parameters, return values, etc
ex) java, c, c++, rust, go
⇒ TypeScript is a static typed language.
In dynamically typed languages all type checks are performed in a runtime, only when your program is executing. So this means you can just assign anything you want to the variable and it will work.
If we take a look at Typescript, it is a statically typed language, so all checks will be performed during compile/build run before we actually execute our program.
Pros and Cons
Pros
- more robust
- easily spot bugs