🔤Basic Types
string / number / booleanPrimitives
string[] / Array<string>Array type
[string, number]Tuple type
anyOpt out of type checking
unknownSafe any — must narrow
neverUnreachable code type
voidNo return value
null / undefinedNull types
objectNon-primitive
symbol / bigintSymbol & BigInt
📦Variable Declarations
const x: string = 'hello'Explicit type
let x = 'hello'Inferred type (preferred)
const x: string | null = nullUnion with null
const x: readonly string[] = []Readonly array
const x = 5 as constConst assertion (literal type)
const x = value as stringType assertion
const x = value!Non-null assertion
📋Interfaces
interface User { name: string }Define interface
interface User { age?: number }Optional property
interface User { readonly id: number }Readonly property
interface Admin extends User {}Interface inheritance
interface Fn { (x: number): string }Call signature
interface Arr { [i: number]: string }Index signature
Declaration mergingMultiple declarations merge
🏷️Type Aliases
type ID = string | numberUnion type
type Point = { x: number; y: number }Object type
type Status = 'open' | 'closed'String literal union
type Pair<T> = [T, T]Generic type alias
type Callback = (err: Error) => voidFunction type
type Keys = keyof SomeTypekeyof operator
type Val = SomeType[keyof SomeType]Indexed access type
🔧Generics
function id<T>(x: T): T { return x }Generic function
function id<T extends object>(x: T)Constrained generic
interface Box<T> { value: T }Generic interface
Promise<string>Generic class usage
Array<T> / Map<K,V> / Set<T>Built-in generics
T extends U ? X : YConditional type
infer RType inference in conditional
🛠️Utility Types
Partial<T>All props optional
Required<T>All props required
Readonly<T>All props readonly
Record<K,V>Object with typed keys
Pick<T,'a'|'b'>Select properties
Omit<T,'a'|'b'>Remove properties
Exclude<T,U>Exclude from union
Extract<T,U>Extract from union
NonNullable<T>Remove null/undefined
ReturnType<typeof fn>Function return type
Parameters<typeof fn>Function param types
Awaited<T>Unwrap Promise type
🏛️Classes
class Foo { constructor() {} }Class definition
private / protected / publicAccess modifiers
readonly prop: stringReadonly field
abstract class / abstract methodAbstract
class Bar extends Foo {}Inheritance
implements InterfaceImplement interface
static prop / static methodStatic members
override method()Override marker
#privateFieldNative JS private field
⚙️Functions
function fn(x: string): void {}Typed function
const fn = (x: string): void => {}Arrow typed
function fn(x?: string): voidOptional param
function fn(x: string = 'def')Default value
function fn(...args: string[])Rest params
function fn(x: string): never { throw }Never return
overload signaturesMultiple signatures
🔭Type Narrowing
if (typeof x === 'string')typeof guard
if (x instanceof Date)instanceof guard
if ('prop' in obj)in operator guard
function isString(x): x is stringType predicate
switch(obj.kind)Discriminated union
const _: never = objExhaustiveness check
🚀Advanced Types
Template literal: `${A}${B}`Template literal type
Uppercase<T> / Lowercase<T>Intrinsic string types
Capitalize / UncapitalizeString manipulation
satisfies operatorValidate without widening
const enumInlined enum values
as const satisfiesCombined pattern
NoInfer<T>Prevent inference
using / await usingExplicit resource management