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

Fixing self imports for typeReference nodes #61107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

navya9singh
Copy link
Member

This pr fixes #58363 and #59827.

@@ -1148,6 +1148,9 @@ export function getExistingLocals(sourceFile: SourceFile, statements: readonly S
if (symbol.valueDeclaration && getSourceFileOfNode(symbol.valueDeclaration).path === sourceFile.path) {
existingLocals.add(symbol);
}
else if (!symbol.valueDeclaration && symbol.parent?.valueDeclaration && getSourceFileOfNode(symbol.parent.valueDeclaration).path === sourceFile.path) {
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 think this is right. I'm not sure we ever should have been using valueDeclaration at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why do you think using valueDeclaration is wrong? Also, another way I had thought of was to do something like this
if (symbol.declarations && some(symbol.declarations, d => getSourceFileOfNode(d).path === sourceFile.path)) { existingLocals.add(symbol); }
but this again would go into another loop and check for each declaration which might probably end up taking even more time. Another way could be to do something like findAllReferences. I'm not exactly clear on what happens there but possible some way of comparing text to see which symbols already exist in a file. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

valueDeclaration only includes value-meaning declarations, and the failing test case here makes it clear why that’s not sufficient. I think looking at symbol.declarations is correct.

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
Status: Waiting on author
3 participants