Mapped types are not all created equal. Homomorphic mapped types preserve modifiers of the mapped type. From the pull request introducing this feature:
With this PR we preserve property modifiers in homomorphic (structure preserving) mapped types. A mapped type of the form
{ [P in keyof T]: X }
is homomorphic withT
(because it has the same set of properties asT
) and now preserves the optional and readonly modifiers as they exist on the properties inT
.
Starting from 2.8 you can remove modifiers from such types using a -
(see PR) :
type Full<T> = {
[P in keyof T]-?: T[P];
}
Note
You can use the predefined Required
type from the standard library which does the exact same thing as Full
.