Type JavaScript with JSDoc
Learn how to add type annotations to JavaScript using JSDoc comments. Cover @type, @param, @returns, @typedef, @template, and how TypeScript reads them.
Type-safe JavaScript with TypeScript
Learn how to add type annotations to JavaScript using JSDoc comments. Cover @type, @param, @returns, @typedef, @template, and how TypeScript reads them.
Learn how TypeScript types promises so you can write async code with confidence. Covers Promise<T>, then/catch chains, and how the compiler catches common async mistakes.
Learn how async and await work with TypeScript's type system. Covers async function return types, typed await expressions, and error handling with try/catch.
Learn to type what a promise resolves to in TypeScript. Covers explicit Promise<T> annotations, inference from async functions, ReturnType, and Awaited for extracting resolved types.
Build a generic fetch wrapper in TypeScript that adds type-safe request and response handling. Learn to type URL parameters, request bodies, and parsed JSON responses.
Learn to model API response types in TypeScript. Covers JSON response shapes, optional fields, discriminated unions for states, and narrowing unknown data from external APIs.
Learn to type and handle API errors safely in TypeScript. Covers error narrowing, discriminated result types, status-code handling, and typed error boundaries.
Learn to use Promise.all with TypeScript's type system. Covers typed tuple results, Promise.allSettled for partial failures, and avoiding common type pitfalls.
Learn to cancel in-flight async requests using AbortController with TypeScript types. Covers AbortSignal, fetch cancellation, cleanup patterns, and typed error handling.
Build a typed retry wrapper in TypeScript with exponential backoff. Learn to type retry configuration, handle transient failures, and preserve response types across retries.
Avoid the most common async TypeScript mistakes. Covers floating promises, missing error handling, Promise.all pitfalls, and async function misunderstandings.
Partial<T> makes every property of a type optional. Use it to describe update payloads, configuration overrides, and any object where only some fields change.