Re:TypeScript: a language for application-scale JavaScript d...
by tlack on Monday October 01, 2012 @01:46PM
(#4598351)
I wish Typescript would add "implied return of last statement" to the short function syntax! I love that feature in Erlang.
[ Parent
| on HN ]
Re:TypeScript: a language for application-scale JavaScript d...
by zem on Monday October 01, 2012 @04:19PM
(#4599135)
that's the feature i'm most surprised they didn't add. coffeescript already does it, for instance.
Re:TypeScript: a language for application-scale JavaScript d...
by ConstantineXVI on Monday October 01, 2012 @05:03PM
(#4599328)
I'm getting the impression that TS is avoiding making too many dramatic changes to JS. Functions that return undefined in vanilla JS would suddenly return whatever happened to be the last statement; likely leading to unexpected behavior.
Re:TypeScript: a language for application-scale JavaScript d...
by zem on Monday October 01, 2012 @05:07PM
(#4599348)
i wonder how hard it would be for their compiler to catch the opposite case, then - a program using the return value of a function without a return statement. i think that was my most common bug when i was doing javascript programming, because all the other languages i was using at the time had implicit returns.
Re:TypeScript: a language for application-scale JavaScript d...
by ConstantineXVI on Wednesday October 03, 2012 @03:53PM
(#4609367)
Closure Tools will let you annotate your functions with a return type; their compiler will catch a function so annotated that lacks a return[0].
[0] http://sixlette.rs/snap/Closure_Compiler_Service-20121003-15...