Created
August 6, 2017 07:31
-
-
Save dested/4230b5dd5e36d1407f9af61511442a09 to your computer and use it in GitHub Desktop.
This file contains 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
export enum MemberActionOptions { | |
DoThis, | |
DoThat, | |
OtherThing | |
} | |
export type MemberAction = { | |
type: MemberActionOptions.DoThis, | |
thisThing: number, | |
} | { | |
type: MemberActionOptions.DoThat, | |
thatThing: number, | |
} | { | |
type: MemberActionOptions.OtherThing, | |
other: number, | |
} | |
let action:MemberAction; | |
action = {type:MemberActionOptions.DoThis, thisThing:12}; //VALID | |
action = {type:MemberActionOptions.DoThat, thatThing:12}; //VALID | |
action = {type:MemberActionOptions.DoThat, thisThing:12}; //COMPILE ERROR | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment