Skip to content

Add missing visitNode call to object literal members #16767

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

Merged
merged 2 commits into from
Aug 24, 2017

Conversation

Yogu
Copy link
Contributor

@Yogu Yogu commented Jun 27, 2017

Object literal elements that are neither spread elements, nor property assignments would not have visitNode called on them. Therefore, the esnext transformer would not be called on them and their children.

Fixes #16765.

@msftclas
Copy link

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@Yogu Yogu changed the title Add missing visitNode call to object literal members WIP: Add missing visitNode call to object literal members Jun 27, 2017
@Yogu
Copy link
Contributor Author

Yogu commented Jun 27, 2017

I added a test case, but now I get the error

Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node MethodDeclaration did not pass test 'isExpression'.

The proposed fix worked fine when I directly changed it in the typescript.js of a project. Can anyone help me out with this? :)

@DanielRosenwasser
Copy link
Member

Thanks for the PR Yogu!

We have a callback in visitNode called test which ensures that the node you're passing has an appropriate type. It's mostly a check to make sure that our assertions are correct. I believe the issue is that you need to update isExpression for the assertion to isObjectLiteralElementLike. Once that works, you should be able to baseline the resulting changes.

@rbuckton can you help look over this PR?

@Yogu
Copy link
Contributor Author

Yogu commented Jun 28, 2017

@DanielRosenwasser Thanks. I wondered why we need to pass the static isExpression all the way down, somehow didn't connect the dots.

Now the build complains that the baseline file has changed. If I locally run the tests and then run jake baseline-accept, I don't get anything to stage into Git, though.

@DanielRosenwasser
Copy link
Member

That's very strange. Are you able to manually add baselines from ./tests/baselines/local to ./tests/baselines/referenceandgit add` that?

@Yogu Yogu changed the title WIP: Add missing visitNode call to object literal members Add missing visitNode call to object literal members Jul 5, 2017
@Yogu
Copy link
Contributor Author

Yogu commented Jul 5, 2017

My bad, now it worked. The build now passes :)

Copy link
Contributor

@rbuckton rbuckton left a comment

Choose a reason for hiding this comment

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

One minor comment. Also, can you resolve the conflict below? Thanks!

@@ -177,7 +177,7 @@ namespace ts {
chunkObject.push(createPropertyAssignment(p.name, visitNode(p.initializer, visitor, isExpression)));
}
else {
chunkObject.push(e as ShorthandPropertyAssignment);
chunkObject.push(visitNode(e as ObjectLiteralElementLike, visitor, isObjectLiteralElementLike));
Copy link
Contributor

Choose a reason for hiding this comment

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

You could remove the cast by changing the type of elements to ObjectLiteralElementLike[].

Yogu and others added 2 commits August 13, 2017 15:11
Object literal elements that are neither spread elements, nor property assignments would not have visitNode called on them. Therefore, the esnext transformer would not be called on them and their children.

Fixes microsoft#16765.
@Yogu
Copy link
Contributor Author

Yogu commented Aug 13, 2017

@rbuckton Thanks for the comments. I resolved the conflicts and applied your suggestion. Can you look over it again?

@rbuckton rbuckton merged commit 40f9ee4 into microsoft:master Aug 24, 2017
@rbuckton
Copy link
Contributor

Thanks for the contribution!

@rbuckton
Copy link
Contributor

@mhegazy should I port this to release-2.5 as well?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 24, 2017

yes please can you port it back.

@rbuckton
Copy link
Contributor

This is now in release-2.5.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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.

5 participants