How to jump to the definition of a inferred type in Typescript?

I use Rubymine, but I am in the minority using Typescript there, so I'll ask over here first in hopes that what I want to do is actually possible.

I can do the following in Typescript:

var someTypedObject : Foo = new Foo();

...A few lines later:

var someObject = someTypedObject;

In this example, someObject will have the type of "Foo" due to type inference.
Furthermore, Webstorm knows this because I can run "View->Evaluate ExpressionType" and it will tell me that it's of type "Foo". So far, so good. But now I want to jump to the definition of Foo. How do I do that?
(In this example, I can just CMD+click on Foo, but I don't always have a type declaration around). How do I tell Typescript to jump to the evaluated type of an expression? This would also be helpful in cases like:

return someFunctionHereThatReturnsBar();

In this case, I have to jump to the method definition, see that it returns a type "Bar", and then jump to Bar. Is it possible to select the function "someFunctionHereThatReturnsBar" and jump directly to the type Bar?

We're considering changing our coding style to rely more upon type inference since the following is often redundant:

var someObject : Foo = someTypedObject;

...but I am hesitant to do so if we lose the ability to quickly determine an object's type and jump to the type defintiion.

Many thanks in advance for any help you can offer.


What about Navigate/Typedeclaration?


I'm afraid that doesn't work. It takes me to the line where I declare the variable, but I don't know how I can just to the type of the variable.


Hmm... for the code like:

class Foo {};

var someTypedObject : Foo = new Foo();

var someObject = someTypedObject;

Ctrl+Shift+B (Navigate/Type Declaration) on 'someObject' jumps to 'class Foo'



Well, it sounds like I'm running into a big difference between Webstorm and Rubymine. I thought that Rubymine would work the same way, so I'm downloading Webstorm now, and will try it there and let you know what I find!


Please sign in to leave a comment.