You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript is an object oriented programming language that is built on top of JavaScript with extra features.
JavaScript is extended to TypeScript
As JavaScript is dynamically typed, the type checking becomes a hassle when working on a big-scale project that requires validation quite often as a result TypeScript is a wise choice to use.
The errors involved with type checking will not be shown if the project is coded in JavaScript as JavaScript informs about errors in runtime rather than in compiled time.
JavaScript does not support OOP. JavaScript uses OOP with the help of syntactic sugar.
Typescript is transpiled to JavaScript and the interesting fact is a developer can choose which version of JS (ES3, ES5, ES6) the TypeScript should be converted to.
Browser cannot run TypeScript
TypeScript can use JavaScript types like number, string, boolean,null, undefined, object and symbol
TypeScript has its own types like Interface, Void, Array, Tuple, Enum , Union and Intersection
Increase productivity by giving suggestions what you have used like the types and number of parameters when using a code of a different file
Takes less time in testing as bugs are easy to find and also few bugs will be available
Type complexities like a small code will also needs it types to be mentioned
Limited Library Support, Over Engineering and Migration Challenges
NVM means node version manager
Day 2
To allow node to run TypeScript you need the TypeScript compiler to compile the code into JavaScript
Write tsc filename.ts
You won't ge typescript types on runtime because the code will be compiled to JavaScript
With TypeScript types we get help for not making mistakes
Tuple is kind of like an array where the order of type of value can be defined
To keep a value fixed,the value needs to be used as a type. This is called literal. With ? means the object property may exist.
With readonly, you cannot overrride an object property.
Functions in objects are called methods
Day 3
TypeScript globally access all the variables so if you write same variable name in another file it will show error. To avoid that, write all the code in {}