Bruce
Bruce

Reputation: 162

Can I make "Go to definition" jump to TypeScript code in Visual Studio 2013?

WebStorm has a nice feature for TypeScript: I can right-click on a function reference in a *.html file, either inside a script tag or inside an event handler for a dom element (e.g. 'onclick'), and when I select Go To Declaration, it gives me the option to select the TypeScript definition, so I can jump straight to the TypeScript code.

I'm trying to do something similar in Visual Studio 2013. Since Visual Studio doesn't seem to support this out of the box, I tried a hack that I thought might work. I defined a "link" file, with a "links.ts" file name, which actually contains 100% valid JavaScript, but links to functions defined within other TypeScript files.

I then add a script reference to links.ts in my html page. The problem is, the "Go To Definition" fails if I reference a ts file, even though if I instead reference links.js, which is identical, it works. Of course, if I reference links.js, then it opens the JavaScript editor, and if I then right-click within the file and go to definitions, it takes me to the *.js files, not to the *.ts files, which is what I want.

Any suggestions?

Upvotes: 2

Views: 3268

Answers (1)

Milan Jaros
Milan Jaros

Reputation: 1147

I'd definitely suggest the ReSharper.

Press Alt + 7 and a get list of useful navigation shortcuts (Navigate to...):

  • F12 - Declaration (when you want to "jump into" declaration from usage),
    • You can also do Ctrl + Click
  • Shift + F12 - Find usages
  • Alt + F12 (this one is not in list but it opens Declaration in the context - to quick overview)

So, the answer: Yes, press F12.

Upvotes: 2

Related Questions