如何在 WebStorm 中找出 TypeScript 元素(变量、函数)的类型? [英] How to find out the type of a TypeScript element (variable, function) in WebStorm?
问题描述
WebStorm 有没有办法获取函数或变量的类型?
Is there a way in WebStorm to get the type of a function or a variable?
在 Visual Studio Code 中,我可以将鼠标悬停在一个标识符上,并获取有关光标下元素的类型信息:
In Visual Studio Code, I can hover over an identifier, and I get type information about the element under the cursor:
它还可以显示变量的有效类型:
It can also show the effective type of a variable:
两者都是非常有用的工具,可以帮助您更好地理解代码.
Both are extremely helpful tools for better understanding the code.
WebStorm 有没有办法在编辑器中访问元素的有效类型?
Is there a way in WebStorm to access the effective type of an element in the editor?
推荐答案
Ctrl+Shift+I(
查看/快速定义
)尝试 Ctrl+Shift+P (
View/Expression Type
) - 它通常显示推断的变量类型Try Ctrl+Shift+P (
View/Expression Type
) - it normally shows the inferred variable type自 WS2017.2 Ctrl+Hover 显示推断类型.
Since WS2017.2 Ctrl+Hover shows inferred type.
这篇关于如何在 WebStorm 中找出 TypeScript 元素(变量、函数)的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!