Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I navigate to original TypeScript file from JavaScript stacktrace in WebStorm with Node?

I'm new to TypeScript. On a Mac I'm using WebStorm 2016.2.4 for Node with TypeScript 2.0.

Interactive debugging works fine using generated maps, but runtime stack trace links point to JavaScript files, not original TypeScript files.

Is this normal and expected? Is there a WebStorm feature I'm missing that can translate those links to the original TypeScript file and line or is this just something TypeScript developers must suffer with?

like image 203
Jackpile Avatar asked Oct 21 '16 09:10

Jackpile


People also ask

Is WebStorm good for TypeScript?

Debugging abilityWebStorm ships with great support for TypeScript, so you get the support from the start without installing any extensions to the core app. This also extends itself to integration for WebPack configuration files and packages. json , helping any development workflow.


1 Answers

I get stack traces using the TypeScript source file line numbers by requiring module source-map-support/register. This can be done a number of ways, e,.g. on the node command line with --require source-map-support/register, or you can require it in your main program. For unit testing, I have it in my mocha.opts file:

--require source-map-support/register
--recursive

Another approach is using the ts-node package

like image 119
Burt_Harris Avatar answered Oct 23 '22 02:10

Burt_Harris