Recall & Review
beginner
What does the
Omit type do in TypeScript?The
Omit type creates a new type by removing one or more specified keys from an existing type.Click to reveal answer
beginner
How do you use
Omit to remove the property age from a type Person?You write
Omit<Person, 'age'> to create a new type without the age property.Click to reveal answer
intermediate
Given
type Person = { name: string; age: number; city: string; }, what is Omit<Person, 'age' | 'city'>?It is a type with only the
name property, because age and city are removed.Click to reveal answer
beginner
Can
Omit be used to remove multiple properties at once?Yes, you can remove multiple properties by listing them as a union of keys, like
Omit<Type, 'key1' | 'key2'>.Click to reveal answer
intermediate
What is the difference between
Pick and Omit types?Pick creates a type by selecting specific keys, while Omit creates a type by removing specific keys.Click to reveal answer
What does
Omit<User, 'password'> do?✗ Incorrect
Omit removes the specified property, so password is removed from User.
Which syntax correctly removes multiple keys using Omit?
✗ Incorrect
Use a union of keys with | to remove multiple properties.
If
type A = {x: number; y: string;}, what is Omit<A, 'z'>?✗ Incorrect
Omit ignores keys not in the type and returns the original type unchanged.
Which is true about Omit?
✗ Incorrect
Omit removes specified properties from a type.
What is the result of
Omit<{a: number; b: string}, 'a'>?✗ Incorrect
Property 'a' is removed, so only 'b' remains.
Explain how the Omit type works and give an example removing a property from a type.
Think about removing keys from an object type.
You got /3 concepts.
Compare Omit and Pick types and describe when you might use each.
One removes keys, the other selects keys.
You got /3 concepts.