-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix crash in extract type and generate get/set refactors #52803
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides the compile error.
src/compiler/utilities.ts
Outdated
@@ -265,6 +266,7 @@ import { | |||
isFunctionLike, | |||
isFunctionLikeDeclaration, | |||
isFunctionLikeOrClassStaticBlockDeclaration, | |||
isFunctionTypeNode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be unused.
(assignment as Mutable<PropertyAssignment>).modifiers = undefined; | ||
(assignment as Mutable<PropertyAssignment>).questionToken = undefined; | ||
(assignment as Mutable<PropertyAssignment>).exclamationToken = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because update
doesn't necessarily create a new node, but the result should still omit error recovery children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, update
only conditionally replaces the node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan that formatting now has to be resilient against every weird grammar recovery node like this. I wish we could just get rid of these nodes from the tree itself - but this seems like a reasonable work-around.
This PR fixes two crashes in refactors related to an attempt to refactor in the presence of a grammar error. This also removes
FunctionType
from the list of nodes that can have illegal modifiers, sinceisStartOfFunctionOrConstructorType
already guards against a function type having modifiers.Fixes #52751