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
Gabritto/issue48313 #51914
base: main
Are you sure you want to change the base?
Gabritto/issue48313 #51914
Conversation
@typescript-bot perf test this |
Heya @gabritto, I've started to run the perf test suite on this PR at b3f78d6. You can monitor the build here. Update: The results are in! |
@@ -27028,6 +27028,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
} | |||
|
|||
function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier) { | |||
const type = getTypeOfSymbol(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.
@ahejlsberg is that at all acceptable? I couldn't really come up with a way to break the dependency between the type computations that arise in the issue, so I'm trying to come up with a way to fix it by changing the order in which we compute things, but I don't know if I can get away with that.
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 have also been wondering about the type resolution stack and how it detects circularity... In the case of this issue for instance, the circularity arises from starting to compute the type of toPart
, then computing the type of index
, and then starting to compute the type of toPart
again.
We detect a circularity even though in between the first push of toPart
and the second push, we have computed and cached the type of index
, and toPart
's type depends on index
's type, so technically the second time we try to compute toPart
would succeed if we allowed it to proceed, because we made progress in between the two attempts to compute toPart
's type.
But we don't detect this progress when deciding if we have a circularity or not, and I don't really understand why, even though I understand how it happens.
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.
Interesting that an initial getTypeOfSymbol
fixes the issue. I think it is a reasonable fix, particularly since it restores the order of resolution that would normally occur.
You're likely right that we'd succeed if we allowed a second attempt at computing toPart
's type to succeed (because we've assigned a contextual type of index
in the process), but it's not easy to know that's the case.
@gabritto Here they are:
CompilerComparison Report - main..51914
System
Hosts
Scenarios
TSServerComparison Report - main..51914
System
Hosts
Scenarios
StartupComparison Report - main..51914
System
Hosts
Scenarios
Developer Information: |
Fixes #48313.