Created
April 9, 2019 16:51
-
-
Save ValentinFunk/85a8204b39e7c73f41c2eaf7c2ec2f57 to your computer and use it in GitHub Desktop.
Revisions
-
ValentinFunk created this gist
Apr 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ export type Discriminate< Union, Prop extends keyof Union, Discriminator extends Union[Prop], > = Union extends { [T in Prop]: Extract<Union[Prop], Discriminator> } ? Union : never; export type DiscriminateByType< Union extends { type: any }, D extends Union['type'] > = Discriminate<Union, 'type', D>;