-
Notifications
You must be signed in to change notification settings - Fork 13k
Avoid an attempt to contextually type static property declaration using itself to avoid spurious circularity #62554
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
base: main
Are you sure you want to change the base?
Avoid an attempt to contextually type static property declaration using itself to avoid spurious circularity #62554
Conversation
…ng itself to avoid spurious circularity
How does this affect this sample? function id<T extends { foo : 0 | 1 }>(x: T): T {
return x
}
const Foo = id(class {
static readonly foo = 0
}); |
It has no effect on this sample. This one works before and after this PR. The more interesting case would be a similar one with a mutable property: function id<T extends { foo : 0 | 1 }>(x: T): T {
return x
}
const Foo = id(class {
static foo = 0
}); This one errors before and after this PR as When there is no constraint (like in the reported issue) the class expression is checked in a deferred fashion (outside of the inference context) and then the contextual type becomes the class expression itself (coming from the already inferred and resolved signature). |
@typescript-bot test it |
Hey @RyanCavanaugh, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
Hey @RyanCavanaugh, the results of running the DT tests are ready. Everything looks the same! |
@RyanCavanaugh Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@RyanCavanaugh Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@RyanCavanaugh Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
fixes #62552