SHARE
TWEET

Untitled

a guest Apr 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export type Discriminate<
  2.   Union,
  3.   Prop extends keyof Union,
  4.   Discriminator extends Union[Prop],
  5. > = Union extends { [T in Prop]: Extract<Union[Prop], Discriminator> } ? Union : never;
  6.  
  7. export type DiscriminateByType<
  8.   Union extends { type: any },
  9.   D extends Union['type']
  10. > = Discriminate<Union, 'type', D>;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top