9 items
Union Type Narrowing Mistake
Type Inference and Union Types
TypeScript Type System Basics
Types, Interfaces, Unions & Inference
Interface Property Type Mismatch
Interfaces and Type Annotations
Basic Types, Interfaces & Annotations
Basic Types & Interfaces
Object type annotations
A union parameter is used without narrowing, causing a type error.
function formatId(id: string | number): string { return id.toUpperCase(); } console.log(formatId(42));
What is the bug in this code?