Skip to content

Instantly share code, notes, and snippets.

@dested
Created August 6, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dested/4230b5dd5e36d1407f9af61511442a09 to your computer and use it in GitHub Desktop.
Save dested/4230b5dd5e36d1407f9af61511442a09 to your computer and use it in GitHub Desktop.
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