Scan frontend job posts: most say React + TypeScript. TS is JavaScript + types โ it compiles to JS and catches a class of bugs before the code ever runs.
What it catches
function total(prices: number[]): number {
return prices.reduce((s, p) => s + p, 0);
}
total(["100", "200"]); // โ compile error โ would've been NaN in prod at 2amThe 20% you actually need
let name: string; let age: number; let ok: boolean;
let tags: string[];
interface Student {
name: string;
cgpa: number;
hostel?: string; // optional
}
type Status = "active" | "placed" | "alumni"; // union โ self-documenting
function greet(s: Student): string { return `Hi ${s.name}`; }Adopting it gradually
- Rename .js โ .ts, fix errors as they surface โ TS allows incremental strictness
- Or start in new projects: Vite scaffolds React+TS with one flag
- Let inference work:
const x = 5already knows it's a number โ don't annotate the obvious
Priority for freshers: JS fundamentals first, TS after React basics. It appears in interviews as "why types?" โ answer: "bugs move from runtime to compile time, and the editor becomes documentation."