EduFlow
Advanced TypeScript Patterns

Checkpoint: Type-Level Programming

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

What is F?

TypeScript
type Flags<T> = { [K in keyof T as T[K] extends boolean ? K : never]: T[K] };
type F = Flags<{ giftWrap: boolean; note: string; express: boolean }>;
Question 2 of 5

What is X?

TypeScript
type IdOf<T> = T extends { id: infer I } ? I : never;
type X = IdOf<{ id: number } | { id: string } | { name: string }>;
Question 3 of 5

What is `on${Capitalize<'shipped' | 'cancelled'>}`?

Question 4 of 5

What is Draft<{ readonly id: number; status: string }>?

TypeScript
type Draft<T> = { -readonly [K in keyof T]?: T[K] };
Question 5 of 5

What is ElementOf<readonly string[]>?

TypeScript
type ElementOf<T> = T extends (infer E)[] ? E : T;

5 questions unanswered