TypeScript Types Demystified: Simple Types, Special Types, and Type Inference A developer explains TypeScript's type system, covering basic types, type inference, arrays, tuples, union types, and special types like any, unknown, never, and void. The post emphasizes letting TypeScript infer types for local variables while being explicit for function parameters and return types. In the first post, we covered why TypeScript exists and how to write your first program. Now it's time to get comfortable with the type system itself — the foundation everything else is built on. By the end of this post, you'll know how to type variables, arrays, and function parameters correctly. You'll also understand the "special" types that trip up most beginners: any , unknown , never , and void . TypeScript's basic types map directly to JavaScript's primitives: js // string let firstName: string = "Ramesh"; let greeting: string = Hello, ${firstName} ; // number no separate int/float — it's all number let age: number = 31; let price: number = 9.99; let hex: number = 0xFF; // boolean let isLoggedIn: boolean = true; let hasAccess: boolean = false; These are the types you'll use most often. Simple, predictable, and exactly what you'd expect. You don't always have to write the type. TypeScript infers it from the value you assign: js let city = "Chennai"; // TypeScript infers: string let year = 2026; // TypeScript infers: number let isActive = true; // TypeScript infers: boolean Once inferred, that type is locked in: js let city = "Chennai"; city = 42; // ❌ Error: Type 'number' is not assignable to type 'string' Rule of thumb: Let TypeScript infer types for local variables. Write explicit annotations for function parameters and return types. js // Let inference work for variables const scores = 95, 87, 72 ; // inferred as number // Be explicit for function signatures function calculateAverage scores: number : number { return scores.reduce a, b = a + b, 0 / scores.length; } // ✅ Explicit annotation — good for function params & return types function formatName first: string, last: string : string { return ${first} ${last} ; } // ✅ Inferred — good for simple variable assignments const result = formatName "Ramesh", "Kumar" ; // inferred as string // ❌ Over-annotating — redundant when value makes it obvious const count: number = 5; // The = 5 already tells TypeScript it's a number Arrays hold multiple values of the same type: js // Two equivalent syntaxes let tags: string = "typescript", "javascript", "react" ; let scores: Array