Skip to content
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

Fixed crash in checkExportsOnMergedDeclarationsWorker #52740

Merged

Conversation

Andarist
Copy link
Contributor

fixes #32231

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Feb 13, 2023
Comment on lines 38811 to 38813
case SyntaxKind.MethodSignature:
case SyntaxKind.PropertySignature:
return getDeclarationSpaces(d.parent as any);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really expect this to be the correct fix (at least not fully). I just pinpointed the place that causes it to crash and some preconditions for the crash.

I don't understand how DeclarationSpaces are used and what values those two should produce here. Note that at the moment we end up with DeclarationSpaces.ExportType in both added cases.

I also don't really understand the given test cases - I understand ESM and CJS but the TS syntaxes like export = _;, export as namespace _ (+ namespaces in general) always confuse me.

I just hope that a capable reviewer can suggest a proper fix 😉 perhaps @andrewbranch is a good person to ask about this stuff

Copy link
Member

Choose a reason for hiding this comment

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

The parent of these kinds can only be TypeLiteralNode | InterfaceDeclaration which are definitely declarations in the type space. You can just add these cases to the top block of cases. I don’t think understanding the test input code is actually necessary or even helpful here 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I changed this line to return DeclarationSpaces.ExportType;. Thanks for the tip! Do you think that this switch/case might also be missing some other member-like kinds from TypeLiteralNode | InterfaceDeclaration?

Copy link
Member

Choose a reason for hiding this comment

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

I don’t know enough about this code path to make sense of what this function needs to handle. I think it’s fine to let it be bug-report-driven at this point.

@sandersn sandersn merged commit 738b45e into microsoft:main Feb 13, 2023
@Andarist Andarist deleted the fix/crash-with-conflicting-declarations branch February 13, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poor error message when names conflict
4 participants