TypeScript lets you declare types for variables, function parameters, and return values.
let count: number = 0;
function add(a: number, b: number): number {
return a + b;
}
Why it matters:
You often don’t need to write types—TypeScript can infer them.
const name = "Saima"; // inferred as string
function multiply(x: number, y: number) {
return x * y; // inferred return type: number
}
Why it matters:
Describe the shape of objects.
interface User {
id: string;
email: string;
}
type Status = "idle" | "loading" | "error";
Why it matters: