What type is y?
let x = "hi";const y = "hi";
What this TypeScript test measures, in short
This test checks whether you can predict what the TypeScript compiler will decide: which type it infers, how it narrows a union, when two shapes count as compatible, and what the built-in utility types produce. It assumes you already know JavaScript.
All snippets assume TypeScript 5 with "strict": true. The questions are our own and are not standardised against a population, so treat the result as a check on your knowledge, not a certification.
By What's Your IQ · Reviewed 4 Oct 2026- Format
- 15 predict-the-type or does-it-compile questions
- Topics
- Inference, narrowing, structural typing and safety, utility types
- Settings
- TypeScript 5.x, strict mode on
- Language
- Released by Microsoft in 2012; led by Anders Hejlsberg
Every check removes a possibility
TypeScript follows your if statements and returns. After each check, it knows the variable can no longer be certain types. Click a line to see what v can still be there.
Types vanish when you compile
function add(a: number, b: number): number { return a + b;}function add(a, b) { return a + b;}Type annotations are simply deleted. Nothing checks at run time that a and b are numbers.
- Microsoft. The TypeScript Handbook and release notes.
- Bierman, G., Abadi, M., & Torgersen, M. (2014). Understanding TypeScript. ECOOP 2014 – Object-Oriented Programming, 257–281.
- Hejlsberg, A. (2025). A 10x faster TypeScript. Microsoft TypeScript blog.