Which of these calls to an overloaded function compile, and what is ReturnType<typeof parse>?
Name the type each ^? line points at, and every error TypeScript reports.
function parse(input: string): number;function parse(input: string[]): number[];function parse(input: string | string[]) { return Array.isArray(input) ? input.map(Number) : Number(input);} const a = parse("4");// ^?const b = parse(["4", "2"]);// ^?const c = parse(Math.random() > 0.5 ? "4" : ["4"]);const d = parse(); type Result = ReturnType<typeof parse>;// ^?Work it out first: the compiler shows every error and type.
The answer
Work out every error TypeScript reports and every type it shows, line by line. Then check.
Checking your sign-in…