๐Ÿ”ท TypeScript Dictionary

Every keyword, operator, and symbol โ€” with plain-English explanations.

string type-system
Primitive type
'hello'
number type-system
Primitive type
123
boolean type-system
Primitive type
true
any type-system
Any type
let x: any = 123;
unknown type-system
Unknown type
let x: unknown = 123;
never type-system
Never type
function neverFunction(): never { throw new Error('Never!'); }
void type-system
Void type
function voidFunction(): void { console.log('Void!'); }
null type-system
Null type
let x: null = null;
undefined type-system
Undefined type
let x: undefined = undefined;
object type-system
Object type
let x: object = {};
type type-system
Type definition
type User = { name: string; age: number; }
enum type-system
Enum type
enum Color { Red, Green, Blue }
implements type-system
Implements interface
class MyClass implements MyInterface {}
interface interfaces
Defines the shape of an object
interface User { id: number; name: string; }
extends interfaces
Extends an interface or class
interface Admin extends User { role: string; }
readonly interfaces
Makes a property immutable after initialization
interface Point { readonly x: number; readonly y: number; }
optional-property interfaces
Property that may be absent โ€” marked with ?
interface Config { timeout?: number; }
const-enum enums
Enum inlined at compile time โ€” no runtime object
const enum Status { Active = 1, Inactive = 0 }
generics generics
Parameterizes types for reusable code
function identity<T>(arg: T): T { return arg; }
generic-constraint generics
Limits generic type with extends
function getLen<T extends { length: number }>(arg: T): number { return arg.length; }
keyof advanced-types
Returns a union of the keys of a type
type Keys = keyof User; // "id" | "name"
typeof advanced-types
Gets the type of a variable or expression
const config = { port: 8080 }; type Config = typeof config;
infer advanced-types
Infers a type variable within a conditional type
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
conditional-type advanced-types
Type that resolves based on a condition
type IsString<T> = T extends string ? true : false;
mapped-type advanced-types
Creates new type by transforming properties of existing type
type Nullable<T> = { [K in keyof T]: T[K] | null };
union advanced-types
Type that can be one of several types
type ID = string | number;
intersection advanced-types
Combines multiple types into one
type AdminUser = User & Admin;
tuple advanced-types
Fixed-length array with specific types per position
let coord: [number, number] = [10, 20];
Partial utility-types
Makes all properties of T optional
function update(user: Partial<User>) {}
Required utility-types
Makes all properties of T required
type FullUser = Required<User>;
Readonly utility-types
Makes all properties of T readonly
const user: Readonly<User> = { id: 1, name: 'Alice' };
Record utility-types
Creates object type with keys K and values T
const roles: Record<string, string[]> = { admin: ['read','write'] };
Pick utility-types
Selects a subset of properties from T
type NameOnly = Pick<User, 'name'>;
Omit utility-types
Excludes specified properties from T
type WithoutId = Omit<User, 'id'>;
Exclude utility-types
Removes types from union T that are assignable to U
type NonString = Exclude<string | number, string>; // number
Extract utility-types
Extracts from T types assignable to U
type Strings = Extract<string | number, string>; // string
NonNullable utility-types
Removes null and undefined from T
type Clean = NonNullable<string | null | undefined>; // string
ReturnType utility-types
Gets the return type of a function type
type R = ReturnType<typeof getUser>; // User
Parameters utility-types
Gets the parameter types of a function as a tuple
type P = Parameters<typeof fetch>; // [input: RequestInfo, init?: RequestInit]
Awaited utility-types
Unwraps the resolved type of a Promise
type T = Awaited<Promise<string>>; // string
as type-guards
Type assertion โ€” tells TypeScript to treat a value as a specific type
const input = event.target as HTMLInputElement;
is type-guards
Type predicate โ€” narrows type in if blocks
function isString(val: unknown): val is string { return typeof val === 'string'; }
instanceof type-guards
Checks if a value is an instance of a class
if (err instanceof Error) { console.log(err.message); }
satisfies type-guards
Validates type without widening โ€” preserves literal type
const palette = { red: [255,0,0] } satisfies Record<string, number[]>;
non-null-assertion type-guards
Asserts value is not null/undefined with !
const el = document.getElementById('app')!;
optional-chaining type-guards
Short-circuits on null/undefined with ?.
const name = user?.profile?.name;
nullish-coalescing type-guards
Returns right side when left is null or undefined
const port = config.port ?? 8080;
abstract classes
Declares a class or method that must be implemented by subclasses
abstract class Shape { abstract area(): number; }
declare modules
Declares a type without emitting JavaScript
declare const window: Window & typeof globalThis;
namespace modules
Groups related code under a named scope
namespace Utils { export function log(msg: string) {} }
noImplicitAny tsconfig
Errors when TypeScript cannot infer a type as not-any
// tsconfig.json: "noImplicitAny": true
strictNullChecks tsconfig
Makes null and undefined not assignable to other types
// tsconfig.json: "strictNullChecks": true
strict tsconfig
Enables all strict type-checking options at once
// tsconfig.json: "strict": true
target tsconfig
Sets the JavaScript version to compile to
// tsconfig.json: "target": "ES2022"
paths tsconfig
Maps module paths to filesystem locations
// tsconfig.json: "paths": { "@/*": ["./src/*"] }
async-await async
Async function returns a Promise; await unwraps it
async function fetchUser(id: number): Promise<User> { return await api.get(id); }
Promise async
Built-in generic type for async values
const p: Promise<string> = fetch(url).then(r => r.text());
template-literal-type advanced-types
Creates string union types using template syntax
type EventName = `on${Capitalize<string>}`;
decorators decorators
Annotations that attach metadata or modify class behavior
@Component({ selector: 'app-root' }) class AppComponent {}
Array built-ins
Generic array type
const nums: Array<number> = [1, 2, 3];
Map built-ins
Typed key-value collection
const m = new Map<string, number>(); m.set('a', 1);
Set built-ins
Typed collection of unique values
const s = new Set<string>(['a', 'b', 'a']); // size: 2