TypeScript Output Prediction Medium +20 XP
Partial Utility Type
What does Partial<User> do?
TypeScriptRead-only
interface User { name: string; age: number; }
type PartialUser = Partial<User>;What is the output?
Show answer and explanation
Answer: Makes all fields optional
Partial<T> constructs a type with all properties of T set to optional. Equivalent to adding ? to every field.
Hint: Partial makes things... partial.
What this challenge tests
Output Prediction in TypeScript: utility-types, partial.