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

旧巷老猫 提交于 2020-01-03 07:22:50

问题


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?


回答1:


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 us using the ts-node package



来源:https://stackoverflow.com/questions/40173619/how-do-i-navigate-to-original-typescript-file-from-javascript-stacktrace-in-webs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!