Skip to content

Conversation

CyrusNajmabadi
Copy link
Contributor

Fixes #2250

… interpreted as a block instead of an object literal.
@JsonFreeman
Copy link
Contributor

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about when it's a type assertion in a parenthesized expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a test for that as well.

@DanielRosenwasser
Copy link
Member

Add the following tests

var a = () => <Error>{ name: "foo", message: "bar" };      

var b = () => (<Error>{ name: "foo", message: "bar" });    

var c = () => ({ name: "foo", message: "bar" });           

var d = () => ((<Error>({ name: "foo", message: "bar" })));

CyrusNajmabadi added a commit that referenced this pull request Mar 7, 2015
When emitting an arrow function, parenthesize the body if it could be interpreted as a block instead of an object literal.
@CyrusNajmabadi CyrusNajmabadi merged commit ac56aa5 into master Mar 7, 2015
@CyrusNajmabadi CyrusNajmabadi deleted the expressionToBlock branch March 7, 2015 10:21
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lambda function with object literal generates invalid ES6 code
4 participants