How to find out the type of a TypeScript element (variable, function) in WebStorm?

Is there a way in WebStorm to get the type of a function or a variable?

In Visual Studio Code, I can hover over an identifier, and I get type information about the element under the cursor:

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/PF8G6.jpg" alt="Hover in VSCode">

It can also show the effective type of a variable:

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/0NYav.jpg" alt="Hover in VSCode">

Both are extremely helpful tools for better understanding the code.

Is there a way in WebStorm to access the effective type of an element in the editor?

Answer1:

    <li>

    Ctrl+Shift+I</kbd> (View/Quick Definition)

    </li> <li>

    Try Ctrl+Shift+P</kbd> (View/Expression Type) - it normally shows the inferred variable type

    </li> </ul>

    Since WS2017.2 Ctrl+Hover</kbd> shows inferred type.

    人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:How to find out the type of a TypeScript element (variable, function) in WebStorm?