TypeScript

Type-safe JavaScript with TypeScript

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

Union Types in TypeScript

A union type lets a value be one of several types. Learn how to define unions, work with them safely, and avoid the most common union mistakes.

TypeScript
Jul 17, 2026· 6 min read

Intersection Types in TypeScript

An intersection type combines multiple types into one. Learn the & syntax, how it differs from extends, and when to use intersection types over interface inheritance.

TypeScript
Jul 17, 2026· 7 min read

Discriminated Unions in TypeScript

A discriminated union uses a shared literal property to tell TypeScript exactly which variant of a union you are working with. Learn the pattern, exhaustiveness checking, and when to use it.

TypeScript
Jul 17, 2026· 6 min read

Use the in Operator for Type Narrowing

JavaScript's in operator checks if a property exists on an object. TypeScript uses it as a type guard to narrow union types by property presence. Learn how it works and when to use it.

TypeScript
Jul 17, 2026· 7 min read

Custom Type Guards in TypeScript

Custom type guards let you define your own narrowing logic with the `parameterName is Type` return syntax. Learn how to write them, filter arrays, and compose guards for complex types.

TypeScript
Jul 17, 2026· 6 min read

Exhaustive Checks in TypeScript

Exhaustiveness checking makes the compiler catch unhandled union variants. Learn the `never`-based pattern, the `assertNever` helper, and how to guarantee every case is covered.

TypeScript
Jul 17, 2026· 7 min read

Common Union Type Mistakes in TypeScript

Avoid the most frequent union type mistakes in TypeScript: forgetting to narrow, misusing intersections for unions, ignoring the typeof null trap, and skipping exhaustiveness checks.

TypeScript
Jul 17, 2026· 6 min read

Tuples in TypeScript Explained

A tuple is an array with a fixed length where each position has its own type. Learn how tuples differ from arrays, when to use them, and how they catch out-of-bounds errors.

TypeScript
Jul 17, 2026· 6 min read

Variadic Tuples in TypeScript

Variadic tuples let you spread an array type into a tuple, creating flexible patterns like 'a string, then any number of booleans, then a number'. Learn the ...Type[] syntax and when to use it.

TypeScript
Jul 17, 2026· 5 min read

Indexed Access Types in TypeScript

Indexed access types look up the type of a specific property from another type. Learn the syntax, how to use unions and keyof as index types, and practical patterns for type-safe property access.

TypeScript
Jul 17, 2026· 6 min read

Create a tsconfig File

A tsconfig.json file tells TypeScript how to compile your project. Learn how to create one, what the key sections mean, and which options to set first.

TypeScript