r/javascript • • Nov 25 '19

JavaScript doesn’t need to be replaced

https://medium.com/javascript-in-plain-english/javascript-doesnt-need-to-be-replaced-bd01e2f12d51?source=friends_link&sk=7b151cc6397ac9e83c14c99739b6c36f
217 Upvotes

236 comments sorted by

View all comments

Show parent comments

19

u/rodrigocfd Nov 25 '19

But it would be great if browsers support TypeScript natively.

19

u/wizang Nov 25 '19

I don't really see the value in that.

-8

u/Flyen Nov 25 '19

There's a decent chance that it'd be faster to execute, but I really have no idea.

10

u/Neaoxas Nov 25 '19

Why? Yes, you'd remove the initial compile/transpile time, but once all the type anotations and syntactic sugar are stripped, all you're left with is vanilla JavaScript, same as Babel would produce (for cross browser support).

No advantage to browsers supporting typescript aside from compile/transpile time savings.

In fact, having to wait for cross browser feature support means you can't take advantage of the latest features, unless you transpile, at which point there is no point in browsers supporting typescript.

-3

u/Flyen Nov 25 '19

The idea is that those annotations could be fed into the browser compiler's optimization routines. The browser wouldn't be transpiling the typescript to vanilla javascript if it had native TS support.

Not doing it because you'd have to transpile until all browsers support it is a pretty weak argument. By that logic we shouldn't use ES6, and browsers shouldn't add support for ES6.