Explore Library
Code QuizAdvanced

Union Type Narrowing Mistake

A union parameter is used without narrowing, causing a type error.

Codetypescript
function formatId(id: string | number): string {
  return id.toUpperCase();
}

console.log(formatId(42));

What is the bug in this code?