-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Set parents of augmented module exports #59609
Set parents of augmented module exports #59609
Conversation
@typescript-bot test it |
Hey @andrewbranch, the results of running the DT tests are ready. Everything looks the same! |
@andrewbranch Here are the results of running the user tests with tsc comparing Everything looks good! |
@andrewbranch Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Perf tests seem similar to what happened in the other version (that just copied the unmerged symbol) #58965 (comment) |
@andrewbranch Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change better than #59582 because it fixes the problem closer to its source, even though it's riskier. But I wonder whether problem has an even earlier source, to do with parents of symbols from export lists.
@@ -2683,7 +2683,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
} | |||
if (source.exports) { | |||
if (!target.exports) target.exports = createSymbolTable(); | |||
mergeSymbolTable(target.exports, source.exports, unidirectional); | |||
mergeSymbolTable(target.exports, source.exports, unidirectional, target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the symbols in target.exports
already have parent set to target
?
source.forEach((sourceSymbol, id) => { | ||
const targetSymbol = target.get(id); | ||
target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol)); | ||
const merged = targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember: can targetSymbol
or sourceSymbol
be returned from mergeSymbol
or getMergedSymbol
? Or is the result always a fresh transient symbol?
The reason I'm asking is that I want to know what happens if we already have an existing parent
. Is it guaranteed to be the same as parent
? Related to it in some way?
source.forEach((sourceSymbol, id) => { | ||
const targetSymbol = target.get(id); | ||
target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol)); | ||
const merged = targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol); | ||
merged.parent ??= parent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from discussion with @iisaduan -- do we know which merged symbols don't have parents? Is it related to whether sourceSymbol
(or target) has a parent? Isabel tracked it down to exports lists=no parent; exported interface=parent. Is there something missing in the binder when parents are set?
@typescript-bot test it |
Hey @andrewbranch, the results of running the DT tests are ready. Everything looks the same! |
@andrewbranch Here are the results of running the user tests with tsc comparing Everything looks good! |
@andrewbranch Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@andrewbranch Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Fixes #58907
Alternative to #59582 and #58965