...
TypeScript is a superset of JavaScript that adds static typing, making your code more reliable and easier to debug.
✅ Developed by Microsoft
✅ Compiles to plain JavaScript
✅ Works with all JavaScript frameworks (React, Angular, Vue)
✅ Used in enterprise apps and modern frontend projects
TypeScript allows you to define what type of data a variable should hold.
let age: number = 22;
let name: string = "Maya";
let isOnline: boolean = true;
If you assign a wrong type, TypeScript will show an error before running the code.
Arrays with type enforcement:
let scores: number[] = [90, 85, 78];
Tuples store fixed types and positions:
let user: [string, number] = ["Christian", 21];
Define the input and output type of a function:
function add(a: number, b: number): number {
return a + b;
}
You can also use optional and default parameters:
function greet(name: string = "Guest"): void {
console.log("Hello " + name);
}
Interfaces define the shape of an object. They’re like contracts.
interface Student {
name: string;
age: number;
major?: string; // optional
}
let s1: Student = {
name: "Maya",
age: 22
};
TypeScript supports full object-oriented programming with classes, inheritance, and access modifiers.
class Person {
private name: string;
constructor(name: string) {
this.name = name;
}
greet(): string {
return "Hello, " + this.name;
}
}
You can extend one class from another using extends.
Enums are used for readable constants:
enum Role {
Student,
Teacher,
Admin
}
let userRole: Role = Role.Teacher;
Union Types allow a variable to accept multiple types:
let status: string | number = "Active";
status = 1;
Generics make code flexible and reusable while preserving type safety.
function identity<T>(value: T): T {
return value;
}
identity<number>(5);
identity<string>("Hello");
Also, you can use conditions to guard types:
function printId(id: string | number) {
if (typeof id === "string") {
console.log(id.toUpperCase());
} else {
console.log(id.toFixed(2));
}
}
✅ Works perfectly with React, Angular, Vue, Node.js
✅ Common in enterprise and startup-level web apps
✅ Use with tsconfig.json for compiler settings
✅ Easily integrate into existing JavaScript codebases
Install Node.js
Install TypeScript using npm install -g typescript
Write .ts files
Compile using tsc filename.ts
Link compiled .js file in HTML or run it with Node.js
Frontend Developer (React, Angular)
Full Stack Developer (Node.js + TypeScript)
Mobile App Developer (React Native + TS)
Cloud/Serverless Dev (AWS, Firebase)
Software Engineer – Enterprise Web Apps