TypeScript is a syntactic superset of JavaScript which adds static typing.
This basically means that TypeScript adds syntax on top of JavaScript, allowing developers to add types.
JavaScript is a loosely typed language. It can be difficult to understand what types of data are being passed around in JavaScript.
In JavaScript, function parameters and variables don't have any information! So developers need to look at documentation, or guess based on the implementation.
A common way to use TypeScript is to use the official TypeScript compiler, which transpiles TypeScript code into JavaScript.
javascript | typescript |
---|---|
JavaScript is a prototype-based language. | TypeScript is known as an Object-oriented programming language |
weakly typed | strongly typed |
used for small projects | used to big projects |
mostly Runtime error | mostly compile time error |
Runs directly to browser | it's need a transpiler to convert to js |
easy to write but hard to maintain | hard to write but easy to mmaintain |