Skip to content

Conversation

@rbuckton
Copy link
Contributor

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, since isStartOfFunctionOrConstructorType already guards against a function type having modifiers.

Fixes #52751

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 16, 2023
Copy link
Member

@jakebailey jakebailey left a 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.

isFunctionLike,
isFunctionLikeDeclaration,
isFunctionLikeOrClassStaticBlockDeclaration,
isFunctionTypeNode,
Copy link
Member

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.

Comment on lines +266 to +268
(assignment as Mutable<PropertyAssignment>).modifiers = undefined;
(assignment as Mutable<PropertyAssignment>).questionToken = undefined;
(assignment as Mutable<PropertyAssignment>).exclamationToken = undefined;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a 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.

@rbuckton rbuckton merged commit 55eff14 into main Feb 16, 2023
@rbuckton rbuckton deleted the fix52751 branch February 16, 2023 21:15
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

'Extract type' from property signature with erroneous initializer causes assertion failure

5 participants