-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Arrow functions require no line terminator before arrow =>
token
#2282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do we need/want to enforce the same restriction in TypeScript or just ensure that the ES6 emit for arrow functions doesn't preserve such newlines? It would be a breaking change to disallow this now, we've been allowing this for ES5: var x = ()
=> {} emits var x = function () {
}; |
I should have clarified: var x = (a)
=> 1 should translate to: var x = (a);
=> 1; // syntax error, unexpected `=>` |
I think it's unlikely anyone is using this syntax, since it's much harder to read, but if it breaks apps then it might not be worth fixing. |
@CyrusNajmabadi and I just discussed this offline; apparently we've sort of known about this, but haven't committed to it since it's a breaking change. That said, he and I would prefer to take the breaking change. |
I just noticed this today while working on implementing rest parameters in arrow functions in v8. v8 and SpiderMonkey are both getting this wrong right now, but Traceur and Babel both get this right.
It's probably a pretty simple fix
The text was updated successfully, but these errors were encountered: