Skip to content

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

Closed
caitp opened this issue Mar 10, 2015 · 4 comments · Fixed by #2283
Closed

Arrow functions require no line terminator before arrow => token #2282

caitp opened this issue Mar 10, 2015 · 4 comments · Fixed by #2283
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@caitp
Copy link
Contributor

caitp commented Mar 10, 2015

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

@danquirk
Copy link
Member

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 () {
};

@caitp
Copy link
Contributor Author

caitp commented Mar 10, 2015

I should have clarified:

var x = (a)
  => 1

should translate to:

var x = (a);
  => 1; // syntax error, unexpected `=>`

@caitp
Copy link
Contributor Author

caitp commented Mar 10, 2015

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.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Breaking Change Would introduce errors in existing code labels Mar 10, 2015
@DanielRosenwasser
Copy link
Member

@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.

caitp added a commit to caitp/TypeScript that referenced this issue Mar 10, 2015
caitp added a commit to caitp/TypeScript that referenced this issue Mar 10, 2015
@mhegazy mhegazy added the Help Wanted You can do this label Mar 11, 2015
caitp added a commit to caitp/TypeScript that referenced this issue Mar 11, 2015
caitp added a commit to caitp/TypeScript that referenced this issue Mar 13, 2015
caitp added a commit to caitp/TypeScript that referenced this issue Mar 15, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 16, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 16, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants