About TypeScript Quizzes
TypeScript adds a powerful static type system to JavaScript, catching entire categories of runtime errors at compile time. But TypeScript's type system goes far beyond simple type annotations — it includes generics, conditional types, mapped types, template literal types, and inferred types that can express complex type relationships that JavaScript cannot.
QuizBytesDaily's TypeScript quizzes help you understand not just the syntax but the semantics of TypeScript's type system. Why does `unknown` require a type narrowing check but `any` doesn't? What's the difference between `interface` and `type` alias? How do you write a generic function that preserves the literal type of its argument? When should you use `as const`?
We cover practical TypeScript patterns used in real codebases: discriminated unions for exhaustive switch statements, utility types (`Partial`, `Pick`, `Omit`, `ReturnType`, `Awaited`), the `satisfies` operator, strict null checks, module augmentation, and the `infer` keyword for conditional type inference. These are the patterns that separate TypeScript users from TypeScript engineers.
Why Learn TypeScript?
What You'll Find in Our TypeScript Quizzes
- ✓Structural vs. nominal typing and type compatibility
- ✓Generics: constraints, defaults, and higher-kinded patterns
- ✓Utility types: Partial, Required, Pick, Omit, Record, Extract, Exclude
- ✓Conditional types and the `infer` keyword
- ✓Mapped types and template literal types
- ✓Discriminated unions and exhaustive type checking
- ✓Strict mode flags and their practical implications
Other Quiz Categories
Sample TypeScript Quiz Questions
A taste of what you'll find in the TypeScript quiz series.
What is the difference between `unknown` and `any` in TypeScript?
Explanation: `any` is a TypeScript escape hatch — you can assign anything to it and use it as anything, but you lose all type safety. `unknown` is the type-safe alternative: you can assign any value to `unknown`, but you cannot call methods, access properties, or pass it where a specific type is expected without first narrowing it with a type guard (typeof, instanceof, or a custom predicate). Prefer `unknown` over `any` whenever you genuinely don't know the type.
What does the `Partial<T>` utility type do in TypeScript?
Explanation: `Partial<T>` constructs a new type with all properties of T set to optional. It is equivalent to `{ [K in keyof T]?: T[K] }`. This is useful for update/patch functions where you only want to accept a subset of fields: `function updateUser(id: string, patch: Partial<User>)`. The counterpart is `Required<T>`, which makes all properties non-optional.
What is a discriminated union in TypeScript and what makes it useful?
Explanation: A discriminated union (also called a tagged union) is a union where each member has a shared property with a unique literal value — the discriminant. For example: `type Shape = { kind: 'circle'; radius: number } | { kind: 'square'; side: number }`. TypeScript uses the `kind` property to narrow the type in a switch statement, and with `strictNullChecks` enabled, the compiler will warn you if you add a new union member but forget to handle it in a switch — enabling exhaustive type checking.
Ready to test your TypeScript knowledge?
Free daily quizzes — no signup, no account, no cost.
Start TypeScript Quizzes →