Skip to content

Instantly share code, notes, and snippets.

@akshayjai1
Created October 2, 2020 14:41
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 akshayjai1/84624f49846604926929ecc284c69577 to your computer and use it in GitHub Desktop.
Save akshayjai1/84624f49846604926929ecc284c69577 to your computer and use it in GitHub Desktop.
typescript type for redux dispatch
import { Dispatch } from 'redux';
export interface IDom {
value?: string;
name?: string;
className?: string;
style?: any;
}
export interface IEvent {
target?: IDom;
currentTarget?: IDom;
}
export type thunkApiType = BaseThunkAPI<any, any, any, any>;
declare class RejectWithValue<RejectValue> {
readonly value: RejectValue;
constructor(value: RejectValue);
}
export declare type BaseThunkAPI<
S,
E,
D extends Dispatch = Dispatch,
RejectedValue = undefined
> = {
dispatch: D;
getState: () => S;
extra: E;
requestId: string;
signal: AbortSignal;
rejectWithValue(value: RejectedValue): RejectWithValue<RejectedValue>;
};
export type Action<Payload> = {
type: string;
payload?: Payload;
meta?: any;
};
export type DispatchType = (action: Action<any>) => void;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment