3 ms·
> You really think a TS->WebAssembly compiler is less likely to have bugs than a TS->JS transpiler (which essentially just strips out the type annotations)? Yea
by BinaryIdiot 11y ago
> You really think a TS->WebAssembly compiler is less likely to have bugs than a TS->JS transpiler (which essentially just strips out the type annotations)? Yeah, no.
Absolutely. Why wouldn't it? Converting to a very explicit byte code type environment versus a language meant to be used by humans?
> I have no idea how these things are relevant. Why would adding type annotations to your code affect your ability to write unit tests. What does dogfooding have to do with anything?
The context of the discussion was around creating libraries for everyone to consume. If you're not testing your code as if it's being run from just JavaScript then you have a blindspot.
TypeScript is not only annotations. Check out the code it generates to support those annotations.
- tlrobinson 11y ago> Why wouldn't it? Whereas TypeScript/Babel/etc perform relatively simple source code transformations, you'd have to implement an entire JavaScript engine in WebAssembly. It would almost certainly be slower and buggier than all of the big 4 JS engines. > Check out the code it generates to support those annotations. Ok, let's do that: http://www.typescriptlang.org/Playground#src=interface%20Person%20%7B%0A%20%20%20%20firstname%3A%20string%3B%0A%20%20%20%20lastname%3A%20string%3B%0A%7D%0A%0Afunction%20greeter(person%20%3A%20Person)%20%7B%0A%20%20%20%20return%20%22Hello%2C%20%22%20%2B%20person.firstname%20%2B%20%22%20%22%20%2B%20person.lastname%3B%0A%7D%0A%0Avar%20user%20%3D%20%7Bfirstname%3A%20%22Jane%22%2C%20lastname%3A%20%22User%22%7D%3B%0A http://www.typescriptlang.org/Playground#src=interface%20Per...