Annotated solution
Published July 28, 2026The solution
type MyPartial<T> = { [K in keyof T]?: T[K] }
The common wrong answer
type MyPartial<T> = { [K in keyof T]: T[K] | undefined }
This widens the value type but leaves the key required: you must still write `{ id: undefined }` rather than omitting it. Optionality and "may be undefined" are genuinely different properties, and exact-equality checks can tell them apart.
Line by line
{ [K in keyof T]?: T[K] }The `?` is a mapped-type modifier. It sits between the key clause and the colon, and it adds optionality to every key produced by the mapping.
keyof TMapping over `keyof T` rather than a supplied key set is what makes this apply to the whole object. Compare `Pick`, where the key set is an argument.
Takeaway
Modifiers (`?` and `readonly`) attach to the mapping, not the value. `-?` and `-readonly` strip them again, which is how `Required` is written.

