Given #14224, I think that Partial should be defined as follows:
type Partial<T extends object> = {
[K in keyof T]?: T[K]
}
Readonly could be defined similarly.
I don't necessarily know if Pick should be defined that way. Part of me thinks that this Pick has a different intent.
mapped type in general handle primitives differently. but i agree that these types should not be used on a primitive.
the problem now is in any generic function every-time you write Partial<T> you have to constrain T extends object.
I have recently used Partial<> like this:
type Foo<T> = {
[K in keyof T]: Partial<T[K]>
}
Wouldn't the constraint prohibit this? Of course, I could create my own Partial<> definition that skips the constraint.
Too annoying to force authors to constrain their own type parameters to object if we did this
Most helpful comment
Too annoying to force authors to constrain their own type parameters to
objectif we did this