Re:TypeScript Is Surprisingly OK for Compilers
by AgentME on Friday August 18, 2023 @07:02AM
(#37173978)
Typescript is defined to run exactly as the equivalent Javascript you get when all the type declarations are stripped out of the source. There's no benefit in compiling it to WASM unless you had a WASM JS engine (or JS->WASM converter) that executed JS faster than the browser's built-in JS engine (or created WASM binaries that were smaller than compressed minified JS, which seems extra unlikely when you'd have to include a JS runtime). If that existed, browsers would just upgrade to use that internally on all JS.
[ Parent
| on HN ]
Re:TypeScript Is Surprisingly OK for Compilers
by hibbelig on Friday August 18, 2023 @08:51AM
(#37174942)
Your parent suggested to make changes to TS so that TS is no longer compatible with JS (in the sense you described). Once that happens, compiling to WASM instead of transpiling to JS is a very valid design choice.
Re:TypeScript Is Surprisingly OK for Compilers
by wiseowise on Friday August 18, 2023 @12:20PM
(#37177895)
The whole purpose of TS is better JS.
Re:TypeScript Is Surprisingly OK for Compilers
by AgentME on Friday August 18, 2023 @11:09PM
(#37185088)
That's fair, though there have been several projects that have attempted to be "JS-ish but with some behavior changes with strict type handling sprinkled in for optimizations" like the Strong types proposal (cancelled) and Dart (which switched to being a compile to JS language just like Typescript), so I'm currently convinced that the trade-offs aren't obviously worth it and that it's unlikely Typescript will change its priorities in that direction in the near future.