You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Destructure and spread on generics not typing #33579
Type '{ key: number; } & Pick<T, Exclude<keyof T, "key">>' is not assignable to type 'T'.
'{ key: number; } & Pick<T, Exclude<keyof T, "key">>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ key: number; }'.
Activity
Nathan-Fenner commentedon Sep 24, 2019
This is behaving as expected, since you don't know that
10is a valid value of typeT["key"]. In particular, consider:So you'd need to instead give a type like:
or like (but this one TypeScript also rejects, which is a design limitation since its flow-sensitive typing is not smart enough):
typescript-bot commentedon Sep 27, 2019
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.