Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspect nested TypeScript interfaces & types in VSCode

When using VSCode with TypeScript I find myself constantly hovering over functions or objects to inspect their type.

Often, the types and interfaces for these objects rely on multiple other interfaces and types. So hovering doesn't give much info.

To inspect the type I have to go manually into e.g. node modules to find the type declaration and inspect it there.

Is there a way to inspect nested types easily in VSCode?

Here is an example:

enter image description here

I'd love an easy way to inspect the interface that is React.FunctionComponent.

like image 986
Xen_mar Avatar asked Jan 27 '20 09:01

Xen_mar


2 Answers

I don't know if this is what you are looking for exactly but :

enter image description here

Press the key ctrl to show details when hovering

enter image description here

Also, ctrl + left click will go to the interface declaration, so you could see the full details.

I don't think that there is enough space to display all the nested interfaces details using hovering anyway. Going to the declaration seems the most appropriate way to get your information.

like image 163
Orelsanpls Avatar answered Oct 22 '22 08:10

Orelsanpls


Also, you could use ALT + F12 shortcut to trigger peeked editor.

For me personally, this is the most convenient way to peek into some component's info without changing the main context.

See more info in docs: https://code.visualstudio.com/docs/editor/editingevolved#_peek

like image 37
Ilya B Avatar answered Oct 22 '22 06:10

Ilya B