3 ms·
Ignoring the type declarations gives some freedom to type checkers to decide what meaning they have, but it also makes them useless to the runtime. I think that
by TazeTSchnitzel 5y ago
Ignoring the type declarations gives some freedom to type checkers to decide what meaning they have, but it also makes them useless to the runtime. I think that's a shame. Could JavaScript engines not benefit from the type information? PHP does.
- olliej 5y agoJS engines would not benefit significantly from the annotations (there may be some slight wins in code density through coalesced checks, but there would be increases in other data structures). Explicit types in this case are primarily a tool to make writing large scale software easier. But ignoring the types is actually worse than “not being helpful”, as it both locks in the current syntax (unlike claims it does provide space for experimentation), and it means that engines cannot in future start enforcing the types specified with this syntax.