-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Propagate variance reliability #62604
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?
Conversation
@typescript-bot test it |
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.
Pull Request Overview
Introduces variance reliability propagation in the type checker and updates related test baselines to reflect new performance characteristics.
- Adds early instantiation/reporting for unmeasurable/unreliable variance flags in the checker.
- Updates an existing baseline with higher instantiation count and adds performance stats to another baseline file.
- Refactors placement of source/target extraction (s/t) outside a conditional.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/compiler/checker.ts | Adds propagation of variance reliability flags and moves s/t extraction earlier. |
tests/baselines/reference/deeplyNestedMappedTypes.types | Updates expected instantiation count (performance metric change). |
tests/baselines/reference/circularlySimplifyingConditionalTypesNoCrash.types | Adds new performance stats section to the baseline. |
Comments suppressed due to low confidence (2)
src/compiler/checker.ts:1
- [nitpick] The return value of instantiateType is ignored; if this call is made purely for its side-effect (invoking the mapper callback), add a clarifying comment or explicitly discard with void to document intent and prevent future refactors from mistakenly removing it.
import {
src/compiler/checker.ts:1
- instantiateType is invoked even when the variance later proves to be Independent (the subsequent branch skips all work for independent parameters); consider deferring this call until after confirming variance !== VarianceFlags.Independent to avoid unnecessary instantiation overhead.
import {
//// [tests/cases/compiler/deeplyNestedMappedTypes.ts] //// | ||
|
||
=== Performance Stats === | ||
Type Count: 1,000 |
Copilot
AI
Oct 15, 2025
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.
Instantiation count increased from 5,000 to 25,000; please confirm this regression is intentional or add justification/mitigation (e.g. a note in the PR or follow-up optimization plan) since this may impact compile performance.
Type Count: 1,000 | |
Type Count: 1,000 | |
// NOTE: High instantiation count is intentional for this test case. | |
// This test is designed to stress-test recursive mapped types (see #55535). |
Copilot uses AI. Check for mistakes.
Hey @ahejlsberg, the results of running the DT tests are ready. There were interesting changes: Branch only errors:Package: raphael
|
@ahejlsberg 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! |
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
@typescript-bot test it |
Hey @ahejlsberg, the results of running the DT tests are ready. There were interesting changes: Branch only errors:Package: raphael
|
@ahejlsberg 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! |
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Only two things to note from tests. First, check time for For background, the error in type IDBValidKey = number | string | Date | BufferSource | IDBValidKey[]; I suppose the additional structural checking caused by propagation of |
This PR implements proper propagation of the
VarianceFlags.Unreliable
flag. See discussion here.Initially this PR propagated both
VarianceFlags.Unreliable
andVarianceFlags.Unmeasurable
, but this had pretty severe effects on thexstate
project that we use in our performance benchmarks. It likely would affect other projects in a similar manner. It is no big surprise since flagging variance as unmeasurable causes us to pretty much always perform structural comparisons. The PR now only propagatesVarianceFlags.Unreliable
, which fixes the reported issue and has an insignificant effect on performance (check time increases ~1% forxstate
).Fixes #62606.