Skip to content

Conversation

@iisaduan
Copy link
Member

@iisaduan iisaduan commented Aug 9, 2024

This adds a check to importFixes/autoimports that finds the parent if symbol.parent does not exist.

When merging symbols that are exported through export lists and then augmented in module augmentations (for example, interfaces), the merged symbol does not have a parent. The augmentations work correctly with the merged symbols not having parents. Since the parent is not needed for typechecking and seems to only be needed in this case of autoimports, we will save memory by continuing to not set .parent. (we can revisit this if we see .parent is needed elsewhere in the future).

Fixes #58907
Closes #58965 (more info in comment)
(the aliased case mentioned here still crashes but because of a different autoimports bug, so opened up a new issue: #59583)

addImport(first(info));
}

function getExportedSymbolParent(symbol: Symbol, checker: TypeChecker): Symbol {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is something that will only be relevant for import fixes. Could any other code crash similarly due to a missing parent?

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice/convenient if the checker set the parent, but I thought it was better not to touch the checker and add a bunch of parent pointers to everyone’s program if tsc never needs them. We could try it and see if it shows up in the perf run. At least, we should have a comment here explaining that this function is making up for an arguable checker deficiency.

Copy link
Member

Choose a reason for hiding this comment

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

Tried in #59609

@iisaduan
Copy link
Member Author

closed by #59609

@iisaduan iisaduan closed this Aug 15, 2024
@iisaduan iisaduan deleted the autoimport-moduleAugment branch August 15, 2024 23:20
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 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

4 participants