Back to the Catalog
typescript
javascript

TypeScript Type System: Deep Cuts

20 questions

Narrowing you can trust, the any/unknown/never/void lattice, structural-typing surprises, and literal widening with as const & satisfies. Every explanation compiles the snippet so a wrong answer becomes a lesson.

Questions

  1. Not answered. After this typeof guard, what is the type of x?
  2. Not answered. Which guard narrows Fish | Bird by checking for a property?
  3. Not answered. Why is val still unknown inside the if?
  4. Not answered. Why does token.length error inside the listener?
  5. Not answered. What forces a compile error when a new union member is forgotten?
  6. Not answered. Which line fails to compile?
  7. Not answered. Which type is the type-safe top type of TypeScript?
  8. Not answered. Does this compile?
  9. Not answered. Is the assignment to name a type error?
  10. Not answered. Reduce the intersection: what single type is string & number?
  11. Not answered. Where does never (not any) silently show up?
  12. Not answered. Which assignment errors on the extra z property?
  13. Not answered. Does const p: Point = v; compile?
  14. Not answered. Why does a one-argument callback satisfy map?
  15. Not answered. Why does getUser(raw) fail but getUser(raw as UserId) succeed?
  16. Not answered. What is the type of config.mode?
  17. Not answered. What are the inferred types of a and b?
  18. Not answered. What is the type of pair?
  19. Not answered. Which keeps the precise inferred type and validates against the constraint?
  20. Not answered. Which assertion makes [3, 4] infer as a readonly tuple readonly [3, 4]?