Skip to main content

Type Signature · #22 · 2026-04-26

What is the type of `r`?

TypeScript ·Difficulty 2/3

How to play

Read the TypeScript snippet and pick the correct type from four choices. Think about inference, narrowing, and utility types. Press 1–4 or click to answer.

function parse(input: string): number;
function parse(input: number): string;
function parse(input: string | number) {
  return typeof input === 'string' ? parseInt(input) : String(input);
}
const r = parse('42');

Loading your progress...

Press 1 through 4, or tap a numbered choice, to answer. Back to hub