Courses
TypeScript Intermediate: Types That Survive Real Projects
Check Yourself: Types That Transform Other Types
Five scenario questions on utility types and mapped types. If you miss more than one, reread the lessons in this section.
Course content
Join this Course
Sign in to save your progress.
-
Generics Without the Fog
-
Generic Functions That Keep the Input Type
-
Generic Types for Lists, Results and Caches
-
-
-
Types That Transform Other Types
-
Utility Types: Partial, Pick, Omit and Record
-
Mapped Types You Can Actually Read
-
-
-
Working With Code You Didn't Write
-
@types Packages and When DefinitelyTyped Is Wrong
-
Typing fetch JSON Without Lying to Yourself
-
-
-
Classes and Modules in TypeScript
-
Classes With public, private and protected
-
Modules, Exports and Avoiding Circular Types
-
-
-
Strictness That Pays Off
-
unknown vs any and Safe Parsing
-
Discriminated Unions for API Responses That Vary
-
-
- Final Check: TypeScript Intermediate
1.
A function update takes a product and changes typed as Partial of Product, and returns a new product built with the spread of both. A caller passes the object price undefined. What happens?
It is a run-time error, because a spread cannot hold undefined.
It compiles, and the price in the result is undefined at run time, even though the type says number.
It compiles, and the old price is kept, because undefined is ignored by the spread.
It is a compile error, because undefined is not a number.
2.
You derive a public type with Omit of User and the key passwordhash, written with a lowercase h. The real property is passwordHash. What does the compiler say?
3.
type Warehouse is the union of the words north and south. You write const stock as Record of Warehouse and number, with an object that has only north. What does the compiler do?
4.
You see the line type Same of T as an object with the key K in keyof T and a value of T indexed by K, with a question mark after the bracket. Which utility type does it match?
5.
Validators of T is a mapped type that gives each key of T a function taking T indexed by that key and returning a boolean. You add a phone field to the Signup type but forget its validator. What happens?
The compiler adds a default validator that always returns true.
A run-time error, the first time phone is validated.
The compiler reports that phone is missing from the validators object, because the mapped type wants one function per key.
Nothing, because the validators object can have fewer keys than the type.
About
Five scenario questions on utility types and mapped types. If you miss more than one, reread the lessons in this section.
- Duration
- 5 min
- Last update
- 10/11/2026
Was this helpful?
0
0
Comments (0)
Sign in to commentNo comments yet.