AI Wisdom
Learning Track

TypeScript Deep Dive

Generics, utility types, conditional types, mapped types, Zod, type guards and module resolution — mastering the TypeScript type system.

12+
Topics
8
Published
100%
Free
Browse articles ↓

12 articlesin TypeScript Deep Dive

TypeScript Deep Dive
Adopting strict TypeScript: flags are enabled one at a time per package with CI blocking regressions, noUncheckedIndexedAccess makes lookups possibly undefined, module resolution matches the runtime, and project references speed up monorepo builds.Adopting strict TypeScript: flags are enabled one at a time per package with CI blocking regressions, noUncheckedIndexedAccess makes lookups possibly undefined, module resolution matches the runtime, and project references speed up monorepo builds.

tsconfig.json: The Complete Guide

Foundational

Compiler options, strict mode, target vs lib, project references, and a pragmatic strategy for adopting strict mode on a legacy codebase.

Updated 13 min
Read →
TypeScript Deep Dive
Template literal types for event names: entity and action unions build valid names like order:created, a payload map types each handler, infer extracts route parameters, and unions are kept small to avoid TS2590.Template literal types for event names: entity and action unions build valid names like order:created, a payload map types each handler, infer extracts route parameters, and unions are kept small to avoid TS2590.

Template Literal Types Guide

AdvancedPRO

String manipulation at the type level — pattern matching, type-safe routes, and event name validation.

Updated 12 min
Read →
TypeScript Deep Dive
Making TypeScript resolve imports like the runtime: Node-run code uses nodenext with .js extensions, bundled apps use bundler mode, path aliases move to package.json imports because tsc does not rewrite them, and CI starts the built output.Making TypeScript resolve imports like the runtime: Node-run code uses nodenext with .js extensions, bundled apps use bundler mode, path aliases move to package.json imports because tsc does not rewrite them, and CI starts the built output.

Module Resolution Demystified

Intermediate

Node, Node16, Bundler — understand how TypeScript actually finds and resolves your import paths, and why it breaks at runtime anyway.

Updated 12 min
Read →
TypeScript Deep Dive
Two decorator systems in one repo: the NestJS service keeps legacy experimental decorators with emitted metadata for dependency injection, a new library uses standard TC39 decorators, and a plain withLogging function works from both.Two decorator systems in one repo: the NestJS service keeps legacy experimental decorators with emitted metadata for dependency injection, a new library uses standard TC39 decorators, and a plain withLogging function works from both.

TypeScript Decorators: Legacy vs Modern

AdvancedPRO

TC39 Stage 3 decorators vs legacy experimentalDecorators — class, method, and field decorators for metadata and cross-cutting concerns.

Updated 13 min
Read →
TypeScript Deep Dive
Typing JavaScript and extending libraries: a small .d.ts declares only the functions you use, Express Request is augmented with user inside a module file so it merges rather than replaces, any-casts are removed, and your own packages emit declarations.Typing JavaScript and extending libraries: a small .d.ts declares only the functions you use, Express Request is augmented with user inside a module file so it merges rather than replaces, any-casts are removed, and your own packages emit declarations.

Declaration Files: The Complete Guide

Intermediate

.d.ts files and @types — type definitions for JavaScript libraries, ambient declarations, and module augmentation.

Updated 13 min
Read →
TypeScript Deep Dive
Assertion functions at a boundary: asserts signatures check the user, cart and config at the top of a handler, throw a clear error at the cause, and narrow types for the rest of the scope instead of non-null assertions.Assertion functions at a boundary: asserts signatures check the user, cart and config at the top of a handler, throw a clear error at the cause, and narrow types for the rest of the scope instead of non-null assertions.

Assertion Functions in TypeScript

Intermediate

asserts condition — functions that narrow types by throwing, for fail-fast validation patterns at function boundaries.

Updated 16 min
Read →
TypeScript Deep Dive
Mapped types derive parallel shapes from a checkout model: per-field errors, touched flags and renamed change handlers through key remapping, plus a DeepPartial that stops at dates and arrays, all covered by type tests.Mapped types derive parallel shapes from a checkout model: per-field errors, touched flags and renamed change handlers through key remapping, plus a DeepPartial that stops at dates and arrays, all covered by type tests.

TypeScript Mapped Types and Template Literals: Transforming Shapes at the Type Level

AdvancedPRO

Mapped types, key remapping, template literal types, and combining them with conditional types to build transformation layers with zero runtime cost.

Updated 14 min
Read →
TypeScript Deep Dive
Conditional types let a return type follow its input: getOrder returns lines only when include is passed, infer extracts element types, wrapping in brackets stops unwanted distribution over unions, and overloads are used when simpler.Conditional types let a return type follow its input: getOrder returns lines only when include is passed, infer extracts element types, wrapping in brackets stops unwanted distribution over unions, and overloads are used when simpler.

TypeScript Conditional Types: Type-Level Logic That Scales

AdvancedPRO

Conditional types, the infer keyword, distributive behaviour, and recursive types — the foundation of every advanced TypeScript utility.

Updated 15 min
Read →
TypeScript Deep Dive
Parsing untrusted data with Zod 4: a schema defines the shape and the TypeScript type is inferred from it, safeParse checks partner responses and request bodies at the boundary, invalid input returns 400 or a fallback, and environment variables are validated at startup.Parsing untrusted data with Zod 4: a schema defines the shape and the TypeScript type is inferred from it, safeParse checks partner responses and request bodies at the boundary, invalid input returns 400 or a fallback, and environment variables are validated at startup.

Zod: Schema-First Validation That Earns Its Type Safety

Intermediate

Parse API responses, form inputs, and env variables with Zod schemas that double as TypeScript types — no more manual type assertions at system boundaries.

Updated 14 min
Read →
TypeScript Deep Dive
Narrowing a payment status union: a switch on the literal status narrows each branch, a never check in the default breaks the build when a new status is added, custom predicates check every field, and catch blocks treat errors as unknown.Narrowing a payment status union: a switch on the literal status narrows each branch, a never check in the default breaks the build when a new status is added, custom predicates check every field, and catch blocks treat errors as unknown.

TypeScript Type Guards: Narrowing Without the Noise

Intermediate

typeof, instanceof, in, discriminated unions, custom type predicates, and assertion functions — the narrowing toolkit that keeps runtime errors out of production.

Updated 12 min
Read →
TypeScript Deep Dive
Deriving types from one source: an Order type produces the list item with Pick, the create payload with Omit, the update payload with Pick plus Partial so the id stays required, and status labels with an exhaustive Record.Deriving types from one source: an Order type produces the list item with Pick, the create payload with Omit, the update payload with Pick plus Partial so the id stays required, and status labels with an exhaustive Record.

TypeScript Utility Types: The Production Toolkit

Intermediate

Partial, Required, Pick, Omit, Record, Extract, Exclude, ReturnType — when to use each and how to compose them for real-world type transformations.

Updated 13 min
Read →
TypeScript Deep Dive
TypeScript generics that mean something: a type parameter must relate inputs to outputs, so fetchJson takes a schema and infers T from it instead of letting callers name any type; constraints and const type parameters keep helpers precise.TypeScript generics that mean something: a type parameter must relate inputs to outputs, so fetchJson takes a schema and infers T from it instead of letting callers name any type; constraints and const type parameters keep helpers precise.

TypeScript Generics: Constraints, Variance, and Inference

Intermediate

Type parameters, constraints, conditional inference, and the patterns that make generics actually useful in production TypeScript.

Updated 14 min
Read →