tc39 / proposal-type-annotations

ECMAScript proposal for type syntax that is erased - Stage 1
https://tc39.es/proposal-type-annotations/
4.23k stars 46 forks source link

Cost benefit analysis #43

Open LifeIsStrange opened 2 years ago

LifeIsStrange commented 2 years ago

A non erased javascript support for type would enable features such as type reflection and reified generics, which improve the expressivity of the language and make it more on par with modern languages. However, currently this proposal is not making any use of the types despite them needed to be parsed or at least properly ignored.

The remaining stated benefit is that this support might (to be defined) reduce transpilation needs for e.g TypeScript. However if I am understanding correctly, in all intellectual honesty this proposal should state that it is not a free lunch and that the cost of transpilation is offsetted to the Javascript parser/interpreter, which must now properly ignore those unused type informations. Therefore you are offloading a one time cost (server side) to N billions of clients times. While support for runtime type reflection might justify such added cost, without it this proposal seems like a net performance loss for end users. There already exist plenty of fast server side TS transpilers such as SWC, esbuild, etc which make the proposal benefit seems even less interesting. What do you think about this?

hinell commented 1 year ago

I agree with @boehs and hope this won't be merged as well. My two cents: