Hacker News new | ask | show | jobs
by ng12 2687 days ago
> TypeScript doesn’t absolve you from learning JavaScript. When things go awry, you’ve still got to be able to spelunk the JavaScript code it produces.

TypeScript code is still 90% regular ES6 JavaScript, of course. That said I very rarely need to go grepping through the transpiled code.

4 comments

> TypeScript doesn’t absolve you from learning JavaScript. When things go awry, you’ve still got to be able to spelunk the JavaScript code it produces.

I've written several projects in Typescript and I don't think I've ever had to analyze the transpiled code. I'm curious how esoteric the situations are where this is still necessary.

I've been using Typescript for three years, both in the browser and in NodeJS. The only time I've seen JS in my debugger is when source maps weren't configured/found. I've never had to fall back to JS for debugging.
Code has bugs. I don’t even write that much typescript and I’ve looked trough the transpiled code just so that when I encounter a bug I’ll be familiar enough to debug through that layer.
Concur. I'm always checking underneath the hood 'because' ... but I have not actually come across a case wherein I've had to.

That said - I think the comment is valid. Transpiling is not compiling and we have not choice but to remain vigilant on the JS, of course, it's not that hard, especially with ES6.

Definitely way less than I used to with CoffeeScript in 2011.

Typescript vs Javascript is less problematic today than modern JavaScript vs browser compatible JavaScript.

Even browser compat JS is slowly going to be almost identical.

The amount of green boxes in this specific feature blows my mind:

https://caniuse.com/#feat=async-functions

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?
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
It's cutting edge ES type annotations.

That's it.