🔷 TypeScript Interfaces & Types
3 exercises — read TypeScript interfaces and type definitions and describe them in plain English. Essential for code reviews, documentation, and onboarding.
0 / 3 completed
Describing TypeScript types — key phrases
- "This is a generic type — the type parameter T allows it to work with any data type."
- "This is a discriminated union — the success field is the discriminant that TypeScript uses to narrow the type."
- "This mapped type iterates over each key of T and…"
- "This utility type creates a version of T where every property is…"
- "E defaults to Error if no second type argument is provided."
1 / 3
Read this TypeScript interface. Which plain-English description is most accurate and useful for a code review?
interface PaginatedResponse<T> {
data: T[];
total: number;
page: number;
pageSize: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
}Option B is the strongest code review description. It: (1) names the pattern (paginated API response — not just "an interface"), (2) explains the generic type parameter with concrete examples (
PaginatedResponse<User>), (3) explains each field in terms of what it means to the consumer ("total number of items across all pages" vs. just "total"), and (4) explains the boolean flags in terms of their use case ("whether more pages exist in either direction"). Option A reads like a dictionary of fields rather than an explanation. Option C mentions "pagination metadata" which is good but doesn't explain the generic parameter. Option D is similar — generic example is there but the field explanations are thin. In code reviews, always explain generics by example and describe fields in terms of how the consumer would use them.