TypeScript infers types of variables when there is no explicit information available in the form of type annotations. Types are inferred by TypeScript compiler when: Variables are initialized. Default values are set for parameters. Function return types are determined.
With WebStorm, you can run and debug client-side TypeScript code and TypeScript code running in Node. js. Learn more from Running and debugging TypeScript.
Although not perfect. Press the Ctrl key (or ⌘ Cmd on macOS) and hover over a variable with the mouse to kick in the inference logic in webstorm :
Assuming the cursor is already on the variable the best way is:
Starting from WS2017.2 Ctrl (Cmd) + Hover shows inferred type.
Also you can try Quick Documentation: Ctrl + Q ( F1 for OS X )
Updated: in 2020.1 it will work as a part of the quick documentation and it works on hover if Preferences > EditoGeneral > Show quick documentation on mouse move is checked
Late to the party, and not sure when this came out, but there is a setting:
Show quick documentation on mouse move. Delay: [500] ms
Where delay is editable.
You can get to it by
File -> Settings -> Editor/General -> #Other / Show quick documentation on mouse move
Works similar to VS
Depending on the context, there are different ways to get type information. (Shortcuts for OS X)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With