iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

TS Quiz

A short TypeScript quiz - types, generics, narrowing, and configuration.

Sample questions

EXAMPLE
# TypeScript quiz

1) Type vs interface for object shapes:
   a) interface only
   b) both work; interface supports declaration merging, type supports unions/intersections
   c) type is deprecated
   d) they are identical

2) The 'unknown' type:
   a) is any
   b) is a safer 'any' - you must narrow before using it
   c) is deprecated
   d) only works on functions

3) Narrowing with 'typeof':
   a) works at runtime, not compile time
   b) helps the compiler narrow the type inside conditional blocks
   c) only works on classes
   d) is a runtime check only

4) Generics let you:
   a) skip types
   b) write reusable functions or types that work with multiple types
   c) coerce values
   d) replace interfaces

5) 'strict' in tsconfig:
   a) is on by default
   b) enables a bundle of options (noImplicitAny, strictNullChecks, etc.) - turn it on
   c) makes builds slow
   d) is for production only

6) Discriminated unions:
   a) are unions where each branch has a literal tag field for narrowing
   b) are deprecated
   c) only work with classes
   d) require enums

7) The 'satisfies' operator (TS 4.9+):
   a) replaces 'as'
   b) checks a value matches a type without widening; the inferred type remains specific
   c) is for assertions
   d) works only with arrays

8) Declaration merging:
   a) does not exist
   b) lets two interfaces with the same name combine their members
   c) is a type cast
   d) is illegal

Answers: 1b, 2b, 3b, 4b, 5b, 6a, 7b, 8b.

Why it matters

Strict mode + discriminated unions + satisfies + unknown over any cover most of what production TypeScript actually rewards. If you nail these, you avoid the worst footguns and ship code that survives refactors.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// Quizzes appear at the end of each lesson — 3 questions each.
console.log('Test yourself when you finish a lesson!');
Try it Yourself »

Exercise

Per-lesson quiz length.

questions

Test yourself

Q1. Per-lesson quiz length is…
Q2. Boss quiz unlocks…
Q3. Quizzes test…

Discussion

Loading…