TypeScript Advanced

Essential Git commands for everyday development — clone, commit, push, pull, and branch management.

Last Updated: May 2, 2026

Advanced TypeScript: conditional types, template literal types, mapped types, infer keyword, discriminated unions, and declaration files.

Conditional Types

PatternType Expression
Basic conditionalT extends U ? X : Y
DistributiveT extends unknown ? ... : never
Exclude nulltype NonNull<T> = T extends null | undefined ? never : T
inferT extends Promise<infer U> ? U : never

Template Literal Types

`${Prefix}${string}`
Match strings starting with a prefix for event names, CSS classes.
Uppercase / Capitalize
Transform literals: Capitalize<'hello'> yields 'Hello'.

Mapped Types

UtilityDefinition
Partial<T>{ [K in keyof T]?: T[K] }
Pick<T, K>{ [P in K]: T[P] }
Key remapping{ [K in keyof T as `get${Capitalize<K>}`]: () => T[K] }

Discriminated Unions

kind field
if (shape.kind === 'circle') narrows type automatically.
Exhaustiveness
default: const _: never = shape;
Pro Tip: Use never type in default case of discriminated union switches for compile-time exhaustiveness checking.