-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version:
3.6.4
Search Terms:
Partial field conditional matching
3.6.4 conditional partial
Code
export type QueryType = (
{ __typename?: 'TypeOne' } & { a: boolean }
) | (
{ __typename?: 'TypeTwo' } & { a: boolean }
) | (
{ __typename?: 'TypeThree' } & { a: boolean }
);
type PickFromUnion<Union, Typename> =
Union extends { __typename?: Typename } ? Union : never;
type FirstType = PickFromUnion<QueryType, 'TypeOne'>;
Expected behavior:
FirstType would be of type { __typename?: 'TypeOne' } & { a: boolean }
Actual behavior:
FirstType is of type QueryType
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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue