keyof Hover bug in VSCode

Viewed 69

So when I hover type as it is shown in the picture result is keyof interface, how can I fix this so I get keys Union as result on hover? BTW it works just fine but it is very annoying.

hover state

1 Answers

It looks like later versions of typescript do not show the resolved union type literals of the keyof operator when hovering over a variable declaration.

I had typescript version 4.6.3 installed globally on my machine. It would not show type infertance resolution on hover.

type PersonProps = keyof Person; // hover on PersonProp shows "keyof Person"

I switched my typescript version to 3.6.2 in my local directory and now I can see

type PersonProps = keyof Person; // hover on PersonProp now shows "name" | "age" | "hasGf" | "contactInfo"

Related