What are basic types in TypeScript

· Category: TypeScript

Short answer

TypeScript extends JavaScript primitives with explicit type annotations and adds tuples, enums, and the special types any, unknown, never, and void.

How it works

Primitive types include string, number, boolean, bigint, symbol, and null / undefined. Complex types include Array<T>, tuples [string, number], and objects. Special types provide escape hatches: any disables checking, unknown requires narrowing before use, never represents impossible values, and void marks functions that return nothing.

Example

let id: number = 42;
let name: string = 'Ada';
let isActive: boolean = true;
let tuple: [string, number] = ['score', 100];
let anything: unknown = fetchData();

Why it matters

Using precise types prevents accidental assignments and clarifies intent. Avoid any in favor of unknown when you genuinely do not know the type ahead of time.