Skip to content

Remove uses of visitNodes and visitNode in visitEachChild #49992

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 3 commits into from
Jul 23, 2022

Conversation

jakebailey
Copy link
Member

Fixes #49310

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 21, 2022
@andrewbranch
Copy link
Member

I don’t understand why this is needed. Don’t synthesized nodes emitted by the TextChanges writer get their pos and end set?

@jakebailey
Copy link
Member Author

jakebailey commented Jul 22, 2022

Not some, it seems. I'll go figure out who's making this array and why it's not getting fixed, then.

(Marking as draft for now so I don't accidentally click the green button.)

@jakebailey jakebailey marked this pull request as draft July 22, 2022 22:34
@andrewbranch
Copy link
Member

It’s still quite possible this is a good fix, I’d just like to understand it a little more.

@jakebailey
Copy link
Member Author

Aha, you were good to wonder. There's a number of long-standing typos in visitEachChild where visitNodes was called instead of nodesVisitor, or visitNode instead of nodeVisitor. Wow!

@jakebailey jakebailey changed the title Don't attempt to skipToEndOf a synthetic node during formatting Remove uses of visitNodes and visitNode in visitEachChild Jul 22, 2022
@jakebailey jakebailey marked this pull request as ready for review July 22, 2022 23:36
@@ -616,7 +616,7 @@ namespace ts {
nodeVisitor(node.argument, visitor, isTypeNode),
nodeVisitor(node.assertions, visitor, isNode),
nodeVisitor(node.qualifier, visitor, isEntityName),
visitNodes(node.typeArguments, visitor, isTypeNode),
nodesVisitor(node.typeArguments, visitor, isTypeNode),
Copy link
Member Author

Choose a reason for hiding this comment

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

This one in particular was the bug.

I tried to come up with a way that would prevent this sort of from happening (like Debug.type<unknown>(visitNodes), or redeclaring it), but wasn't successful in stopping TS from allowing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really, really wonder how many other bugs there are that were caused by this in the wild...

Copy link
Member Author

Choose a reason for hiding this comment

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

wasn't successful in stopping TS from allowing this.

The fix would be to start targeting ES2015 aka ES6, then do const visitNodes = undefined in the body; the only reason that doesn't work now is that we downlevel default parameters to assignments and that interferes with the scoping.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Haha wow. Glad I asked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in 'setTextPos' during 'getCodeFixes'
5 participants