Skip to content

Prevent crash on code fixes on default keyword #48028

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
Mar 4, 2022

Conversation

jakebailey
Copy link
Member

Fixes #48008

default appears as an identifier in the AST, which appears to be expected. Just return undefined to skip the symbol rather than asserting that it's not legal.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 24, 2022

// "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
if (symbolName === InternalSymbolName.Default) {
return undefined;
Copy link

Choose a reason for hiding this comment

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

Suggested change
return undefined;
return;

Copy link
Member Author

Choose a reason for hiding this comment

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

While technically equivalent, I don't think an implicit undefined return is very clear (and this codebase doesn't really do this).

@jakebailey jakebailey changed the title Add failing test case Prevent crash on code fixes on default keyword Feb 25, 2022
@jakebailey jakebailey merged commit 4abad55 into microsoft:main Mar 4, 2022
@jakebailey jakebailey deleted the fix-48008 branch March 4, 2022 18:43
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Inappropriate assertion failure in 'getFixesInfoForNonUMDImport'
4 participants