Code QuizAdvanced

Pick vs Omit with keyof

Using keyof with the wrong utility to isolate extra fields.

Codetypescript
type Base = { id: number; createdAt: Date };
type Full = { id: number; createdAt: Date; name: string; email: string };

// Goal: only the fields that Full adds on top of Base
// -> { name: string; email: string }
type ExtraFields = Pick<Full, keyof Base>;

What is the bug in this code?

Watch the code walkthrough

Watch on YouTube →