-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
add pushTypeResolution to getTypeOfAlias #52642
Conversation
Shouldn't every call to |
That being said, all of the other pops appear to have specific error messages, so we probably will need one for this case (if it ends up fixing the bug). |
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.
This is probably the right fix, but we should just make this a plain compiler test.
It is sort of funny that there's a comment in the middle of this function: // It only makes sense to get the type of a value symbol. If the result of resolving
// the alias is not a value, then it has no type. To get the type associated with a
// type symbol, call getDeclaredTypeOfSymbol.
// This check is important because without it, a call to getTypeOfSymbol could end
// up recursively calling getTypeOfAlias, causing a stack overflow. And the specific thing going wrong here is that |
There's also
commented in |
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
@jakebailey Here they are:
CompilerComparison Report - main..52642
System
Hosts
Scenarios
TSServerComparison Report - main..52642
System
Hosts
Scenarios
StartupComparison Report - main..52642
System
Hosts
Scenarios
Developer Information: |
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 the new error better. Just a couple of small technical suggestions.
@typescript-bot test top200 |
Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 2e126a6. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the regular perf test suite on this PR at 2e126a6. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 2e126a6. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 2e126a6. You can monitor the build here. Update: The results are in! |
src/compiler/checker.ts
Outdated
else if ((symbol.flags & SymbolFlags.Alias) && symbol.declarations?.length) { | ||
error(symbol.declarations[0], Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); |
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.
It doesn't seem like there's anything "importy" about Alias
itself; can we get here via non-import means such that this message will be incorrect?
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'm not sure if we can currently get here via non-import means, but it seems like a good check to add, incase more circularity errors are added in the future.
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 guess this is more of a comment on the specificity of the error; e,g, would the more generic _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation
suffice?
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@jakebailey Here they are:
CompilerComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
StartupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
src/compiler/checker.ts
Outdated
const symbolImport = symbol.declarations?.find(getAnyImportSyntax); | ||
if (symbolImport) { | ||
error(symbolImport, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); | ||
} |
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'm not quite sure getAnyImportSyntax
is the right helper; that seems to be something specific to visibility rules.
Reading the other place where Circular_definition_of_import_alias_0
is used (resolveAlias
), probabably getDeclarationOfAliasSymbol
is a good location to put the symbol.
const symbolImport = symbol.declarations?.find(getAnyImportSyntax); | |
if (symbolImport) { | |
error(symbolImport, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); | |
} | |
const node = getDeclarationOfAliasSymbol(symbol); | |
if (node) { | |
error(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); | |
} |
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.
Are imports always the last declaration? getDeclarationOfAliasSymbol
returns the last declaration that is true for isAliasSymbolDeclaration
, which from
TypeScript/src/compiler/types.ts
Line 5725 in a25321a
Alias = 1 << 21, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker) |
seems like it is similar to only checking for
SymbolFlags.Alias
and may not be specific enough to make sure that the declaration is an import?
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.
No idea; but getDeclarationOfAliasSymbol
also only checks & SymbolKind.Symbol
and then uses this helper to issue the same error.
@typescript-bot test top200 |
Fixes #50928