TypeScript Tutorial
Best Free TypeScript Training Tutorial | Beginner To Advanced Level
- Introduction to TypeScript
- Installing TypeScript
- Write Your First TypeScript Program
- Variables in TypeScript
- Data Types in TypeScript
- If-Else
Introduction to TypeScript
TypeScript is an improved version of JavaScript. It includes everything that JavaScript has, plus extra features like data types, interfaces, and enums.
These features help developers find mistakes while writing code instead of after running it.
TypeScript makes code easier to read, understand, and maintain, especially in large projects.
Before running, TypeScript code is converted into JavaScript because browsers and Node.js can only run JavaScript.
Installing TypeScript
Before TypeScript, you need to install Node.js on your system.
Step 1: Install Node.js
- Visit the official Node.js website:
- Download the LTS (Long-Term Support) version.
- Run the installer and complete the installation.
Verify the Installation
Open Command Prompt or Terminal and run:
node -v
Check the npm version:
npm -v
Step 2: Install TypeScript
Install TypeScript globally using npm:
npm install -g typescript
What does this command mean?
npm→ Node Package Managerinstall→ Installs a package-g→ Installs the package globally, so it can be used from any foldertypescript→ The TypeScript package
Step 3: Verify TypeScript Installation
tsc -v
Write Your First TypeScript Program
Create a file named: hello.ts
let message: string = "Hello, TypeScript!";
console.log(message);Compile the TypeScript File
tsc hello.ts
Run the JavaScript File
node hello.js
Output: Hello, TypeScript!