Hacker News new | ask | show | jobs
by marcosdumay 2687 days ago
Do you debug TypeScript code? If I get the code on the browser to place a breakpoint, it's JavaScript there, is there some way to transpile it so it carries the extra information?
4 comments

That's what source maps are for (same situation as if you use ES6 and/or a framework and end up transpiling via Webpack etc)
sourcemaps are buggy as hell though (browser's devtools, and just generally the specification's problem, not TS's), and a lot of devtool features don't work with them. Debugging non-trivial problems with sourcemaps on is infuriating. It's really rare (though it happens every now and then in complex software) to have to go down to bytecode or native in something like C#, but in JS/TS/whatever, it happens all the time.
Enabling source maps will have the source including type annotations show up in the web inspector, but the information isn't usable by the JavaScript VM to validate types at runtime. This is also necessary to preserve line and column information when debugging.
Source maps do this

    --sourceMap