Re:TypeScript 1.4 sneak peek: union types, type guards, and ...
by Horusiath on Wednesday November 19, 2014 @05:16PM
(#8633024)
I actually like cleanliness of Javascript generated from Typescript code. However I don't think that pattern matching would be more intrusive than, for example, module or class generation. Basically example from above could be compiled down to something like:
var x = getResults();
if(x instanceof Error) { ... }
else if(x instanceof Results) { ... }
Re:TypeScript 1.4 sneak peek: union types, type guards, and ...
by lobster_johnson on Wednesday November 19, 2014 @10:07PM
(#8634221)
All the TypeScript examples use "instanceof". That's what a pattern matching block like this would compile down to, surely. And pattern matching on literals (eg., [x|xs]) would also translate to perfectly adequate JavaScript.
Tomorrow if I want to drop Typescript,I can,because it still outputs readable javascript.Introduce something like pattern matching and it will not be an option anymore.