4 ms·
Yeah it's probably not worth it to add types to JS the language, but what if you could ship standard metadata files similar to source-maps that only included ty
by _bxg1 7y ago
Yeah it's probably not worth it to add types to JS the language, but what if you could ship standard metadata files similar to source-maps that only included type information, which browsers could leverage to speed up compilation?
- WorldMaker 7y agoIn the long term, I hope that at least a compromise like the Python annotation approach could be reached (standardize the parsing, but ignore the semantics). Typescript type annotations share a surface level syntax with them in some ways, and also with ES4's type annotation attempt. "Type maps" are an interesting idea. You could probably piggy back on/boostrap from WASM types.
- tomcam 7y agoSounds good in theory, but it seems like rich territory for mismatched types in the source and map files.
- _bxg1 7y agoI don't see why that would happen; you wouldn't be writing these by hand
- z3t4 7y agoAdding types would probably slow down the code as some optimizations done by the engine wouldnt be allowed. Kinda like when you use bitwise operations for optimization only to find out they actually slow down the code. We could hower add Interface and optional types as syntax sugar for runtime checks.