TypeScript

Type-safe JavaScript with TypeScript

187 tutorials
12 of 187 tutorials
Jul 17, 2026· 6 min read

Unknown Errors in TypeScript

Learn why catch clause variables are typed as unknown instead of any, how to safely narrow them, and how to handle the different kinds of values that can be thrown at runtime.

TypeScript
Jul 17, 2026· 6 min read

Custom Error Classes in TypeScript

Learn how to create custom error classes that extend the built-in Error, add meaningful properties like status codes and field names, and use them with type-safe catch blocks.

TypeScript
Jul 17, 2026· 6 min read

Result Pattern in TypeScript

Learn the Result pattern as an alternative to throwing errors. Model success and failure as plain values so the compiler forces you to handle both cases.

TypeScript
Jul 17, 2026· 7 min read

Runtime Validation in TypeScript

TypeScript types disappear at runtime. Learn how to validate data as it enters your application using type guards, assertion functions, and validation libraries to bridge the gap between compile-time types and runtime reality.

TypeScript
Jul 17, 2026· 7 min read

Parse JSON Safely in TypeScript

JSON.parse returns any, which bypasses TypeScript's type checking. Learn how to parse JSON safely by combining runtime validation with typed parsing so you never trust raw data from a string.

TypeScript
Jul 17, 2026· 7 min read

Validate API Data in TypeScript

API responses arrive as unknown data at runtime. Learn how to validate API responses in TypeScript with type guards, Zod schemas, and a practical fetch wrapper that guarantees type safety.

TypeScript
Jul 17, 2026· 7 min read

Use Zod with TypeScript

Zod is a TypeScript-first schema validation library. Learn how to define schemas, infer types, parse data safely, and handle validation errors so you never trust unvalidated data.

TypeScript
Jul 17, 2026· 7 min read

Throwing Errors vs Result Types in TypeScript

Compare two ways to handle errors in TypeScript: throwing exceptions and returning Result types. Learn when each approach works best and how to combine them in real applications.

TypeScript
Jul 17, 2026· 5 min read

Parameters Utility Type in TypeScript

Parameters<T> extracts the parameter types of a function as a tuple. Use it to reuse parameter types without duplicating them.

TypeScript
Jul 17, 2026· 7 min read

Mapped Types in TypeScript

A mapped type iterates over a union of keys and produces a new object type. Use it to transform every property of a type in one declaration.

TypeScript
Jul 17, 2026· 6 min read

Key Remapping in TypeScript

Key remapping with the as clause lets you rename keys in a mapped type. Use it to prefix, suffix, or transform property names based on their original values.

TypeScript
Jul 17, 2026· 7 min read

Template Literal Types in TypeScript

Template literal types construct new string literal types at the type level, just like template literals build strings at runtime. Use them for string pattern matching and type-safe APIs.

TypeScript