-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
someTypeRelatedToType now passes isIntersectionConstituent #33213
someTypeRelatedToType now passes isIntersectionConstituent #33213
Conversation
@@ -22018,7 +22018,7 @@ namespace ts { | |||
} | |||
} | |||
else { | |||
const allDiagnostics: DiagnosticRelatedInformation[][] = []; | |||
const allDiagnostics: Array<ReadonlyArray<DiagnosticRelatedInformation>> = []; |
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.
const allDiagnostics: Array<ReadonlyArray<DiagnosticRelatedInformation>> = []; | |
const allDiagnostics: (readonly DiagnosticRelatedInformation[])[] = []; |
to fix that lint failure.
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.
Our parsing for readonly T[][]
is so bad, and yet we have a lint rule requiring it.
@typescript-bot cherry-pick this to release-3.6 |
…icrosoft#33213)" This reverts commit 8ca36f3.
…#33213) * someTypeRelatedToType now passes isIntersectionConstituent * Fix [][] lint
isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646
* Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646 * Update comments in test
Component commits: 2e0b451 Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. microsoft#33133 provides an example of such a program. Fixes microsoft#33133 the right way, so I reverted the fix at microsoft#33213 Fixes microsoft#34762 (by reverting microsoft#33213) Fixes microsoft#33944 -- I added the test from microsoft#34646 14d7a44 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key ea80362 Update comments in test 0764275 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key
Component commits: 2e0b451 Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646 14d7a44 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key ea80362 Update comments in test 0764275 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key
The quick check for intersection sources doesn't pass isIntersectionConstituent, which incorrectly causes excess property checking to happen on intersection constituents.
In this example, the quick check happens when checking
g(CC)
, and incorrectly finds thatCP
is not assignable to{ children?: boolean }
even though the latter is part ofCP & { children?: boolean }
. The result is then cached, which breaks the assignability check on the next line:<CC {...(null as CP) }/>
.This is a 3.6 regression, but the example is so complex that I'm not sure how hard it is to reproduce.
Fixes #33133
Edit: Added commentary from the issue:
The basic problem is that the flag
isIntersectionConstituent
, which is used to exempt intersection constituents from common-property checks ("weak types"), isn't threaded through one particular intersection call in assignability checking. I missed it when threading that flag through more calls in 3.6 (#32582), and my new assertion in overload error reporting caught the mistake. It's quite likely that this assert would have fired a lot more before #32582.