Reputation: 3043
The Typescript Pick type is not mapping intellisense in vscode (or stackblitz). If MyType
has a documented property, then you define a type as Pick<MyType, 'someProperty'>
, then you mouseover .someProperty
you won't see the documentation or if you right-click -> Go to Definition it won't find any. It will for Partial<MyType>
though.
I made workaround type PickPartial<T, K extends keyof T>
and demonstration here. Is this a Typescript or vscode bug or how Pick
should behave?
Upvotes: 1
Views: 798
Reputation: 30919
I'm going to call this a TypeScript bug. See this modified demo. In order for the documentation to come through, the constraint of the mapped type has to be just a keyof
; this was implemented here. However, modifiers such as readonly
come through if the constraint is a type parameter whose constraint is a keyof
, as it is in Pick
. Documentation should be changed to come through in the same circumstances that modifiers do.
Upvotes: 2