Skip to content

Instantly share code, notes, and snippets.

@theory-of-soul
Created May 12, 2020 08:27
Show Gist options
  • Save theory-of-soul/90d9bdd3827faec28c4f63476651042d to your computer and use it in GitHub Desktop.
Save theory-of-soul/90d9bdd3827faec28c4f63476651042d to your computer and use it in GitHub Desktop.
good typings for redux
import { AnyAction } from "redux";
export type Wizard = {
name: string;
parentsAlive: boolean;
spells: string[];
};
export const enum WizardActionTypes {
LearnSpell = "WIZARD/LEARN_SPELL",
KillParents = "WIZARD/KILL_PARENTS"
}
export type WizardNamespaceShape = {
[id: string]: Wizard;
};
export interface LearnSpellAction extends AnyAction {
type: WizardActionTypes.LearnSpell;
payload: { id: string; spell: string };
}
export interface KillParentsAction extends AnyAction {
type: WizardActionTypes.KillParents;
payload: { id: string };
}
export type WizardAction = LearnSpellAction | KillParentsAction;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment