Introduction to TypeScript
TypeScript is a programming language which is developed and maintained by Microsoft. It was designed by Anders Hejlsberg (designer of C#) at Microsoft. TypeScript is Typed JavaScript. TypeScript adds types to JavaScript to help you speed up the development by catching errors before you even run the JavaScript code. TypeScript is a strict syntactical superset of JavaScript and adds optional static typing to the language. Simple definition of TypeScript “TypeScript is JavaScript for application-scale development.”
The latest version of Typescript is TypeScript 4.6. which was released to public on
1 March 2022.
Why we need TypeScript?
TypeScript is fast, simple, and most importantly, easy to learn.
TypeScript supports object-oriented programming features such as classes, interfaces, inheritance, generics, etc.
TypeScript cannot be run directly on the browser. so we needs a compiler to compile the file and generate JavaScript file which can run directly on the browser.
Components of TypeScript
TypeScript has three components -
Language − It comprises of the syntax, keywords, and type annotations.
The TypeScript Compiler − TypeScript compiler (tsc) converts the instructions which is written in TypeScript to its JavaScript equivalent.
The TypeScript Language Service − The "Language Service" exposes an additional layer around the core compiler pipeline that are editor-like applications. The language service supports the common set of a typical editor operations like statement completions, signature help, code formatting and outlining, colorization, etc.
Write your first Program in TypeScript
Let us see how to compile and execute a TypeScript program using Visual Studio Code. Follow the steps given below −
Step 1 : Save the file .ts extension like Hello_world.ts as shown below.
let message:string = "Hello World.....!";
console.log(message);
Step 2 : Open terminal and compile the TypeScript file by the following command.
tsc Hell0_world.ts
Run the JavaScript file using the below command
node Hello_world.js
Are you looking for help in Typescript task like project, assignment and Want to chat about your team? We provide team extension services for early-stage startups. Please check out our services page and send a help request at contact@codersarts.com
If you are looking for any kind of Help in Web development assignment help Contact us.
Comments