-
Notifications
You must be signed in to change notification settings - Fork 12.8k
3.6.4 Partial field matching does not work for conditional type #33944
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
Comments
This change happened in 3.6.4, so I'm going to move this into 3.8. |
@crisslion In the meantime, you can work around this by making the discriminant required. Actually, why was the discriminant optional in the first place? |
For the minimal repro:
So |
@sandersn We are generating typescript types from graphQL types so we are using I guess more precise data type we want to pick from is:
So only convenient way to select the right type is using type name. |
I don't understand this part. Can you show me an example of how you omit it when using the type? How would it look if the property weren't optional? |
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
Fix is available at #34789 |
* 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
TypeScript Version:
3.6.4
Search Terms:
Partial field conditional matching
3.6.4 conditional partial
Code
Expected behavior:
FirstType would be of type
{ __typename?: 'TypeOne' } & { a: boolean }
Actual behavior:
FirstType is of type
QueryType
Playground Link:
3.6.3 where it works
http://www.typescriptlang.org/play/?ts=3.6.3#code/KYDwDg9gTgLgBDAnmYcCKBXYVEBVmoC8cAFAFBxwDecA+rUigHYCGAtsAPwBccA5PhQB5JsD5wAvnABk1OC14AjCBAA2wFk0lkAlHAA+pCnPqNgrDj36DguAO4RxU2TQVxlajVom6DRyjSmBBZcvAIEuAAWUMBikjJybh7qmto6ANxkZGZwAAoAlgDGANYAYlAQbACqTPkQTAA8NXVMADRwNiEAfHCExs31cKAw5gAmAM4mDMHsoR0zHPGccANavKIAbtiZ2QRwpflQ4zA2vXlFZRXVtfUNmNh4BO3hwqJ8XelAA
3.7 where it does not work (3.6.4 not provided in playground)
http://www.typescriptlang.org/play/?ts=3.7-Beta#code/KYDwDg9gTgLgBDAnmYcCKBXYVEBVmoC8cAFAFBxwDecA+rUigHYCGAtsAPwBccA5PhQB5JsD5wAvnABk1OC14AjCBAA2wFk0lkAlHAA+pCnPqNgrDj36DguAO4RxU2TQVxlajVom6DRyjSmBBZcvAIEuAAWUMBikjJybh7qmto6ANxkZGZwAAoAlgDGANYAYlAQbACqTPkQTAA8NXVMADRwNiEAfHCExs31cKAw5gAmAM4mDMHsoR0zHPGccANavKIAbtiZ2QRwpflQ4zA2vXlFZRXVtfUNmNh4BO3hwqJ8XelAA
The text was updated successfully, but these errors were encountered: