Skip to content

Commit b109695

Browse files
committed
Revert async action creators started payload type
1 parent 203dcef commit b109695

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/index.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,6 @@ export interface AsyncActionCreators<P, S, E> {
4242
failed: ActionCreator<Failure<P, E>>;
4343
}
4444

45-
export interface EmptySuccess<S> {
46-
result: S;
47-
}
48-
49-
export interface EmptyFailure<E> {
50-
error: E;
51-
}
52-
53-
export interface EmptyAsyncActionCreators<S, E> {
54-
type: string;
55-
started: EmptyActionCreator;
56-
done: ActionCreator<EmptySuccess<S>>;
57-
failed: ActionCreator<EmptyFailure<E>>;
58-
}
59-
6045
export interface ActionCreatorFactory {
6146
(type: string, commonMeta?: Object | null,
6247
error?: boolean): EmptyActionCreator;
@@ -68,9 +53,6 @@ export interface ActionCreatorFactory {
6853
async<P, S>(
6954
type: string, commonMeta?: Object | null,
7055
): AsyncActionCreators<P, S, any>;
71-
async<undefined, S, E>(
72-
type: string, commonMeta?: Object | null,
73-
): EmptyAsyncActionCreators<S, E>;
7456
async<P, S, E>(
7557
type: string, commonMeta?: Object | null,
7658
): AsyncActionCreators<P, S, E>;

tests/typings/index.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,46 @@ function testPayload() {
2323
const g = withoutPayload({foo: 'bar'});
2424
}
2525

26-
function testEmptyAsyncPayload() {
27-
const emptyAsync = actionCreator.async<undefined,
28-
{foo: string},
29-
{bar: string}>('EMPTY_ASYNC');
26+
function testAsyncPayload() {
27+
const async = actionCreator.async<{foo: string},
28+
{bar: string},
29+
{baz: string}>('ASYNC');
3030

31-
const started = emptyAsync.started();
31+
const started = async.started({foo: 'foo'});
3232
// typings:expect-error
33-
const started1 = emptyAsync.started({});
33+
const started1 = async.started({});
34+
// typings:expect-error
35+
const started2 = async.started();
3436

35-
const done = emptyAsync.done({result: {foo: 'foo'}});
37+
const done = async.done({
38+
params: {foo: 'foo'},
39+
result: {bar: 'bar'},
40+
});
41+
// typings:expect-error
42+
const done1 = async.done({
43+
params: {foo: 1},
44+
result: {bar: 'bar'},
45+
});
3646
// typings:expect-error
37-
const done1 = emptyAsync.done({result: {foo: 1}});
47+
const done2 = async.done({
48+
params: {foo: 'foo'},
49+
result: {bar: 1},
50+
});
3851

39-
const failed = emptyAsync.failed({error: {bar: 'bar'}});
52+
const failed = async.failed({
53+
params: {foo: 'foo'},
54+
error: {baz: 'baz'},
55+
});
56+
// typings:expect-error
57+
const failed1 = async.failed({
58+
params: {foo: 1},
59+
error: {baz: 'baz'},
60+
});
4061
// typings:expect-error
41-
const failed1 = emptyAsync.failed({error: {bar: 1}});
62+
const failed2 = async.failed({
63+
params: {foo: 'foo'},
64+
error: {baz: 1},
65+
});
4266
}
4367

4468
function testIsType() {

0 commit comments

Comments
 (0)