Types in typescript

TypeScript's type system includes primitives (string, number, boolean), unions, intersections, literal types, and type aliases. Type annotations catch errors at compile time. The 'any' type opts out of type checking—avoid it when possible.

Example

type Status = 'active' | 'inactive' | 'pending';
type User = {
  id: number;
  name: string;
  status: Status;
  metadata?: Record<string, unknown>;
};

Union types and type aliases create precise, self-documenting type definitions.