feat(redux-api-middleware): add createAction types (#43918)

This commit is contained in:
Andrew Luca 2020-04-16 02:16:14 +03:00 committed by GitHub
parent ce90df6301
commit 3aaa00afc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Type definitions for redux-api-middleware 3.0
// Type definitions for redux-api-middleware 3.2
// Project: https://github.com/agraboso/redux-api-middleware
// Definitions by: Andrew Luca <https://github.com/iamandrewluca>
// Craig S <https://github.com/Mrman>
@ -147,6 +147,10 @@ export type RSAAResultAction<Payload = never, Meta = never> =
export type RSAAActions = RSAARequestAction | RSAAResultAction;
export function createAction<State, Payload, Meta>(
clientCall: RSAACall<State, Payload, Meta>
): RSAAAction<State, Payload, Meta>;
/**
* Redux behaviour changed by middleware, so overloads here
*/

View File

@ -18,6 +18,7 @@ import {
RSAAFailureTypeDescriptor,
RSAARequestAction,
RSAAResultAction,
createAction,
} from 'redux-api-middleware';
{
@ -322,3 +323,14 @@ import {
error: true,
};
}
{
createAction(); // $ExpectError
createAction({}); // $ExpectError
// $ExpectType RSAAAction<any, any, any>
createAction<any, any, any>({
endpoint: '/test/endpoint',
method: 'GET',
types: ['REQ_TYPE', 'SUCCESS_TYPE', 'FAILURE_TYPE'],
});
}