Re:The Great CoffeeScript to Typescript Migration of 2017
by danenania on Friday May 15, 2020 @04:59PM
(#23197322)
What’s wrong with implicit returns? I’ve always liked those in CoffeeScript and Ruby.
[ Parent
| on HN ]
Re:The Great CoffeeScript to Typescript Migration of 2017
by city41 on Friday May 15, 2020 @05:09PM
(#23197437)
It can cause surprises. One of the biggest ones is turning a loop into an expression if it’s the last thing a function does.
Edit: here is an example
https://coffeescript.org/#try:-%3E%20%0A%20%20for%20i%20in%2...
Re:The Great CoffeeScript to Typescript Migration of 2017
by rraval on Friday May 15, 2020 @05:16PM
(#23197525)
Accumulating loop results in an array is bad for perf, but won't necessarily cause logic bugs.
My favourite implicit return gotcha comes from the intersection of CoffeeScript and jQuery, where implicitly returning `false` from an event handler implies `preventDefault()` and `stopPropagation()`. This can even cause heisenbugs if your logging throws booleans around.
Re:The Great CoffeeScript to Typescript Migration of 2017
by dgoldstein0 on Saturday May 16, 2020 @09:34PM
(#23208703)
Another bad one: returning a jQuery.ajax object, and then consumers of your api may start using it directly.
We have that in our codebase still. Not sure if it was intentional or not but it's going to be hard to undo.