Skip to content

Commit 962d0da

Browse files
committed
Check-in missing file
1 parent 2bb35ff commit 962d0da

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/index.d.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,34 @@ export interface Action<P> extends AnyAction {
1010
error?: boolean;
1111
meta?: Meta;
1212
}
13-
export interface Success<P, S> {
13+
export declare type RequiredKeys<T> = {
14+
[P in keyof T]: T[P] extends undefined ? never : P;
15+
}[keyof T];
16+
export declare type Optionalize<T> = Partial<T> & {
17+
[P in RequiredKeys<T>]: T[P];
18+
};
19+
export declare type Success<P, S> = Optionalize<{
1420
params: P;
1521
result: S;
16-
}
17-
export interface Failure<P, E> {
22+
}>;
23+
export declare type Failure<P, E> = Optionalize<{
1824
params: P;
1925
error: E;
20-
}
26+
}>;
2127
export declare function isType<P>(action: AnyAction, actionCreator: ActionCreator<P>): action is Action<P>;
22-
export interface ActionCreator<P> {
28+
export declare type ActionCreator<P> = {
2329
type: string;
2430
match: (action: AnyAction) => action is Action<P>;
25-
(payload: P, meta?: Meta): Action<P>;
26-
}
27-
export interface EmptyActionCreator extends ActionCreator<undefined> {
28-
(payload?: undefined, meta?: Meta): Action<undefined>;
29-
}
31+
} & (P extends undefined ? (payload?: P, meta?: Meta) => Action<P> : (payload: P, meta?: Meta) => Action<P>);
3032
export interface AsyncActionCreators<P, S, E> {
3133
type: string;
3234
started: ActionCreator<P>;
3335
done: ActionCreator<Success<P, S>>;
3436
failed: ActionCreator<Failure<P, E>>;
3537
}
3638
export interface ActionCreatorFactory {
37-
(type: string, commonMeta?: Meta, error?: boolean): EmptyActionCreator;
38-
<P>(type: string, commonMeta?: Meta, isError?: boolean): ActionCreator<P>;
39-
<P>(type: string, commonMeta?: Meta, isError?: (payload: P) => boolean): ActionCreator<P>;
39+
<P = undefined>(type: string, commonMeta?: Meta, isError?: boolean): ActionCreator<P>;
40+
<P = undefined>(type: string, commonMeta?: Meta, isError?: (payload: P) => boolean): ActionCreator<P>;
4041
async<P, S>(type: string, commonMeta?: Meta): AsyncActionCreators<P, S, any>;
4142
async<P, S, E>(type: string, commonMeta?: Meta): AsyncActionCreators<P, S, E>;
4243
}

0 commit comments

Comments
 (0)