Day 7 : TypeScript
TypeScript :
Basic Introduction :
- TypeScript is an open-source, object-oriented programming language.
- TypeScript is developed and maintained by “Microsoft” and introduced by “Anders Hejlsberg”.
- TypeScript is a strongly typed superset of JavaScript.
- TypeScript is the ES6 version of JavaScript with some additional features.
- TypeScript cannot be directly run on the browser.
- TypeScript is a language as well as a set of tools.
Features :
- TypeScript extends JavaScript and makes it strongly typed.
- Strongly typed means when we write the code the datatype is checked.- During the development phase errors and issues are caught.
- All JavaScript code are valid TypeScript code.
- TypeScript gives us benefit of OOP features, classes, closures and IIFE.
- TypeScript is an open-source, object-oriented programming language.
- TypeScript is developed and maintained by “Microsoft” and introduced by “Anders Hejlsberg”.
- TypeScript is a strongly typed superset of JavaScript.
- TypeScript is the ES6 version of JavaScript with some additional features.
- TypeScript cannot be directly run on the browser.
- TypeScript is a language as well as a set of tools.
Features :
- TypeScript extends JavaScript and makes it strongly typed.
- Strongly typed means when we write the code the datatype is checked.
- During the development phase errors and issues are caught.
- All JavaScript code are valid TypeScript code.
- TypeScript gives us benefit of OOP features, classes, closures and IIFE.
Why we use TypeScript instead of JavaScript??
- Firstly JavaScript language is introduced for client-side. After that the Node.js makes JavaScript server-side too.
- However JavaScript is growing, the maintainance and reuse of code becomes difficult.
- So it fails in compile-time error checking, strongly-type checking and also fails to hold the features of object-oriented programming.
- TypeScript is designed to solve these failures. It is a mixture or addition of ES5, ES6 and additional features.
Note:
- TypeScript code can be converted into JavaScript code.
- The TypeScript code has .ts extension.
- It highlights the errors at compilation time.
Installation :
- For installation use the below command in your vs code terminal :
npm install -g typescript
Simple Program :
- After successfully installing typescript, create a file using .ts extension.
- And after writing code, use below command :
// Simple.ts => TypeScript file
> tsc Simple.ts
- This command creates a .js file and now run the below command for output :
> node Simple.js
Program and output :
TS File :
Thank You!!!
For more understanding watch below video :
JavaScript Day 1 : Day 1
JavaScript Day 2 Global Pollution : Day 2 Global
JavaScript Day 2 Undefined and Hoisting : Day 2 Undefined
JavaScript Day 3 : Day 3
JavaScript Day 4 : Day 4
JavaScript Day 5 : Day 5
JavaScript Day 6 : Day 6
Comments
Post a Comment