TypeScript Vocabulary: 30 Terms Every TypeScript Developer Needs
Master essential TypeScript vocabulary — type vs interface, generics, mapped types, utility types, type guards, and more. Real examples for IT professionals.
TypeScript has become the default choice for serious JavaScript projects — yet its terminology can feel overwhelming when you are learning on the job. Understanding the precise meaning of words like discriminated union, mapped type, or type narrowing makes code reviews far less intimidating and pair programming far more productive. This guide walks through 30 essential TypeScript terms with plain-English definitions and realistic developer examples.
Core Type Declarations
type vs interface
A type alias (declared with type) names any TypeScript type expression — primitives, unions, intersections, tuples, and objects. An interface declares the shape of an object and supports declaration merging.
“Should I use a
typeor aninterfacehere?"
"Use aninterfacewhen you’re describing an object shape that other code might extend. Use atypealias for unions, intersections, or anything that isn’t purely an object.”
The practical rule most teams follow: prefer interface for public API surfaces; use type for everything else.
Union Type
A union type says a value can be one of several types, separated by |.
“The
idfield is a union ofstring | number— it accepts both.”
Intersection Type
An intersection type combines multiple types into one using &. The resulting type must satisfy all the combined shapes.
“We created an intersection type
AdminUser & AuditLogso the object carries both the user fields and the audit fields.”
Generics
Generics let you write reusable components that work with different types without losing type information. You declare a type parameter (commonly T) that acts as a placeholder.
“The
fetchData<T>function is generic — pass the response shape asTand you get full autocomplete on the result.”
Type Narrowing and Guards
Type Narrowing
Type narrowing is the process by which TypeScript refines a broad type to a more specific one inside a conditional block. TypeScript understands typeof, instanceof, in, and equality checks.
“After the
if (typeof value === 'string')check, TypeScript narrowsvaluefromstring | numberto juststring— so string methods become available.”
Type Guard
A type guard is a function whose return type is a type predicate (value is SomeType). Calling it in a conditional block narrows the type for TypeScript.
“We wrote a
isApiError(e): e is ApiErrorguard so the catch block knows the exact error shape.”
Discriminated Union
A discriminated union is a union of types that all share a common literal property (the discriminant). TypeScript uses that property to narrow to the correct variant in a switch statement.
“Each action in our Redux store has a
typeliteral — that’s the discriminant. The switch onaction.typegives full narrowing for each case.”
Type Assertion
A type assertion (value as SomeType) tells the compiler to treat a value as a specific type without a runtime check. It is your guarantee, not a cast — it can be wrong.
“We used
as HTMLInputElementto tell TypeScript the element definitely has avalueproperty. But be careful — if you’re wrong, you get a runtime error.”
Advanced Type Constructs
Mapped Type
A mapped type creates a new type by iterating over the keys of an existing type and transforming each property. The { [K in keyof T]: ... } syntax is the signature pattern.
“We built a
Nullable<T>mapped type that makes every propertyT[K] | null— one definition, works for any object type.”
Conditional Type
A conditional type uses T extends U ? X : Y syntax — if T is assignable to U, the type resolves to X; otherwise to Y. They are useful for inferring types inside generic utilities.
“The
NonNullable<T>built-in is a conditional type — it stripsnullandundefinedfromT.”
Template Literal Type
A template literal type builds string literal types using template syntax `prefix_${T}`. It lets you describe patterns like event names or CSS property names at the type level.
“We used a template literal type
`on${Capitalize<EventName>}`to automatically derive handler names from event names.”
Declaration Merging
Declaration merging means TypeScript combines multiple interface declarations with the same name into one. This is how libraries let you augment their types.
“We merged into Express’s
Requestinterface to add ouruserproperty — that’s declaration merging.”
Module Augmentation
Module augmentation is a way to extend types from an external module without modifying its source. You re-open the module with declare module 'module-name' and add to its types.
“To add our custom fields to
express-session, we used module augmentation so TypeScript knows aboutreq.session.userId.”
Utility Types
TypeScript ships a library of utility types — generic helpers for common type transformations.
Partial
Partial<T> makes every property of T optional. Useful for update payloads.
“The PATCH endpoint accepts
Partial<User>— you only need to send the fields you’re changing.”
Required
Required<T> makes every property of T mandatory, removing optional modifiers.
Pick
Pick<T, K> creates a type containing only the specified keys K of T.
“We
Pick-ed justidandnamefrom the fullUsertype for the dropdown list.”
Omit
Omit<T, K> creates a type with all keys of T except those in K.
“The
CreateUserDTOisOmit<User, 'id' | 'createdAt'>— we strip the server-generated fields.”
Record
Record<K, V> constructs a type with keys K and values V. Common for dictionaries and lookup maps.
“
Record<string, number>is a clean way to type a score map.”
Readonly
Readonly<T> makes all properties of T read-only — TypeScript will error if you try to reassign them.
Extract and Exclude
Extract<T, U> keeps only the members of union T that are assignable to U. Exclude<T, U> removes them.
“We used
Exclude<Status, 'deleted'>to get a union of all statuses except'deleted'— useful for the public API.”
Strict Mode and Configuration
Strict Mode
Enabling "strict": true in tsconfig.json turns on a group of stricter checks: strictNullChecks, noImplicitAny, strictFunctionTypes, and others. Most teams enable it from the start.
“We turned on strict mode and had to fix about 200 implicit
anyerrors — worth it for the long-term safety.”
strictNullChecks
With strictNullChecks enabled, null and undefined are not assignable to other types unless explicitly declared. This prevents a whole class of runtime errors.
“Before
strictNullCheckswas on,user.namecould silently beundefinedat runtime. Now TypeScript forces us to handle it.”
noImplicitAny
With noImplicitAny, TypeScript errors if it cannot infer a type and would otherwise fall back to any. It forces explicit annotations on parameters and variables.
Common TypeScript Phrases
| Phrase | Meaning |
|---|---|
”This widens to any” | TypeScript loses type information here |
| ”We need to narrow this” | Add a type guard or conditional to refine the type |
| ”The types don’t align” | Two types are incompatible — assignability fails |
| ”Let’s make this generic” | Replace a hard-coded type with a type parameter |
| ”That’s an unsafe assertion” | as SomeType bypasses the compiler — risky |
| ”The utility type handles this” | Use Partial, Pick, etc. rather than rewriting manually |
| ”It’s structural, not nominal” | TypeScript checks shape, not class identity |