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 isIntersectionConstituent to relation key #34789
Add isIntersectionConstituent to relation key #34789
Conversation
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
@typescript-bot perf test this |
Heya @sandersn, I've started to run the perf test suite on this PR at 2e0b451. You can monitor the build here. It should now contribute to this PR's status checks. Update: The results are in! |
|
||
==== tests/cases/conformance/types/intersection/commonTypeIntersection.ts (2 errors) ==== | ||
declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; | ||
let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // No error! |
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 error?
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's a copy & paste from the issue which expressed surprise that no error was issued here. There should be one (and now there is).
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 should change the comment; it's "No error!" because the OP was surprised at the lack of error.
@@ -118,7 +118,8 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e | |||
~ | |||
!!! error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. | |||
!!! error TS2322: Type 'A & B' is not assignable to type 'B & D'. | |||
!!! error TS2322: Type 'A & B' is not assignable to type 'D'. | |||
!!! error TS2322: Property 'd' is missing in type 'A & B' but required in type 'D'. | |||
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:4:15: 'd' is declared here. |
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 but not awful that we lose the line Type 'A & B' is not assignable to type 'D'.
... and it’s nice that we get the elaboration into the missing properties.
@sandersn Here they are:Comparison Report - master..34789
System
Hosts
Scenarios
|
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 simplifies the code a bit, fixes the issues, produces better errors, and seems to be fine on perf. As with all assignability changes, we should look over the extended test suites, but this looks good to me.
@typescript-bot test this |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@typescript-bot run dt |
whew, the user test baselines were pretty messy! I merged to master so they should be better now. @typescript-bot user test this |
RWC: 5 elaborations in fp-ts change. They do so in a way that makes it embarrassingly obvious that we are linearising multiple elaborations. But otherwise they're fine. Also ha ha oh no I didn't actually merge the baseline updates until 5 minutes ago, so @typescript-bot user test this |
DT had no failures. |
User tests had no failures. |
@typescript-bot cherry-pick this to release-3.7 |
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
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
@weswigham and I considered adding one or two new relations for excess property and common property checks, respectively, since excess property checks are almost as strict as the identity relation, and common property checks are less strict than the subtype relation. But this seems likely to result is a big fix.
Given the number of problems we've had with intersections and excess/common property checks, I think we should ship this fix eventually. I'm not sure if 3.7.x is the right time. We did ship #33213 in 3.6.4, however. My initial feeling is to vote for shipping in 3.7.2.