Comment by javier123454321

3 years ago

Honestly the TC39 is the best case scenario. https://tc39.es/proposal-type-annotations/

Forget runtime type validation, TS is really for preventing bugs at development time as well as IDE integration.

If types were added to javascript it could also dramatically improve the performance of javascript virtual machines (V8 and friends). It seems so silly to me that I write typescript, then the types are erased from my code, sent to the browser, and then the browser tries to infer them as part of its own optimization process.

Adding types to javascript proper would be fantastic.

  • This proposal is not about adding types to JavaScript. This proposal is about new syntax for comments in JavaScript. Virtual machine will not use this information.

  • > If types were added to javascript it could also dramatically improve the performance of javascript virtual machines

    Are you sure? In my understanding modern JS engines basically makes type inference on the code anyway, and in the rare case when types are observed to change at runtime, it is special-cased. So static types might simplify this but I dont see how it would dramatically improve performance.