Type Manipulation

TypeScript lets you compute new types from existing types and values. Instead of writing a UserUpdate type by hand and keeping it in sync with User, you derive it: Partial<Omit<User, "id">>. When User gains a field, every derived type follows, and the compiler flags each place that now needs attention.

The type-level operators mirror JavaScript operations you already know from JavaScript. They run only in the checker and are erased before the code runs (The Basics):

Type operators and their JavaScript counterparts
Type operator Example JavaScript analogy
Generic parameter Box<T> Function parameter
keyof keyof User Object.keys(user)
typeof (type context) typeof config Reading a variable
Indexed access User["email"] user["email"]
Conditional type T extends string ? A : B cond ? a : b (Ternary Operator)
Mapped type { [K in keyof T]: ... } for...in building an object
Template literal type ` on${Capitalize<E>} ` Template string

Subsections