Code QuizAdvanced

Overload Order Shadows the Specific Case

Function overloads are resolved top-down, so a broad signature listed first can hide narrower ones.

Codetypescript
function parse(input: any): any;
function parse(input: string): number;
function parse(input: unknown): unknown {
  return typeof input === "string" ? Number(input) : input;
}

const n = parse("42"); // n is typed as any, not number

What is the bug in this code?