Created
March 3, 2020 15:48
-
-
Save ValentinFunk/d8e40655b8348f32ef5d868187bbc01f to your computer and use it in GitHub Desktop.
Undiscriminiate in Typescript
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 characters
type DiscriminateMessageType< | |
A, | |
T extends BookingMessageNotification['bookingMessageType'] | |
> = A extends BookingMessageNotification ? | |
T extends A['bookingMessageType'] ? A : never | |
: never; | |
asMsg<T extends BookingMessageNotification['bookingMessageType']>(type: T): DiscriminateMessageType<BookingMessageNotification, T> { | |
return this._entry as any; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment