Partial, Pick and Omit
Partial makes all properties optional, Pick keeps some and Omit removes some.
Example
interface U { id: number; name: string; age: number }
const p: Partial<U> = { name: "A" };
const q: Pick<U, "id"> = { id: 1 };
const r: Omit<U, "age"> = { id: 2, name: "B" };
console.log(p, q, r);Result
{
name: "A",
} {
id: 1,
} {
id: 2,
name: "B",
}Exercise
Make optional.
<User>Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.