TYPESCRIPT 5 · STRICT MODE · 15 QUESTIONS · ABOUT 10 MINUTES

Think like the compiler.

Fifteen snippets. For each, say what type TypeScript infers, or whether it compiles at all. Each answer comes with the rule behind it, and your result is broken down by topic.

Start the TypeScript test
let a = "hi";// a: stringconst b = "hi";// b: "hi"const c = [1, "x"];// c: (string | number)[]
c.push(true); ✕ boolean not assignable
QUESTION 1 / 15 · INFERENCEEasy

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
QUESTIONS 7 TO 10, STEP BY STEP

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.

TYPE OF v ON LINE 4
stringnumbernull
v: string | numberIf v were null we'd have returned, so null is ruled out below this line.
WHAT ACTUALLY RUNS

Types vanish when you compile

YOU WRITE · .ts
function add(a: number, b: number): number { return a + b;}
THE BROWSER RUNS · .js
function add(a, b) { return a + b;}

Type annotations are simply deleted. Nothing checks at run time that a and b are numbers.

0 bytesof type checking reach the browserTypeScript deliberately adds no run-time checks. All its safety happens before the code ships, which is why data from outside (APIs, forms) still needs validating.1
2012First release. Microsoft published TypeScript 0.8 as a typed superset of JavaScript: every valid JavaScript file is also valid TypeScript.1
2014Unsound on purpose. A formal study showed the type system knowingly allows some unsafe programs, trading guarantees for compatibility with existing JavaScript.2
2016Strict null checks. TypeScript 2.0 made null and undefined separate types, the change behind question 8 and most of the narrowing on this page.1
2025A native compiler. The team announced a port of the compiler to Go, aiming for roughly ten times faster builds on large projects.3
  1. Microsoft. The TypeScript Handbook and release notes.
  2. Bierman, G., Abadi, M., & Torgersen, M. (2014). Understanding TypeScript. ECOOP 2014 – Object-Oriented Programming, 257–281.
  3. Hejlsberg, A. (2025). A 10x faster TypeScript. Microsoft TypeScript blog.

Where to go next

Knowing TypeScript is one thing. How do you reason?

Our full IQ test measures the logic and working memory that type puzzles lean on: 60 questions across four domains, about 30 minutes.

Take the full IQ test