Hacker News new | ask | show | jobs
by MrJohz 1294 days ago
In theory this might be the case, but in practice all the TS compiler needs to do to produce valid JS code is strip the type declarations from the input. There are a couple of minor exceptions (enums don't exist natively in JS, and are replaced with objects, and things get a bit more complex if you use decorators), but in general idiomatic Typescript code should look the same as equivalent idiomatic Javascript code.

This gets a bit more complicated in some setups because the typescript compiler can also transpile modern JS/TS code to older versions, doing a similar job to Babel, but this doesn't have to be the case, and in practice this tends to be fairly orthogonal to the question of Typescript: you can compile to older versions regardless of whether you use Typescript, and you can use Typescript regardless of whether you compile to older versions.

So in practice, there will be no difference between a Typescript program and an equivalent idiomatic Javascript version, because Typescript is just Javascript with syntax for type hints.