diff --git a/docs/Glossary.md b/docs/Glossary.md index 03ded27dcc..35eaf95531 100644 --- a/docs/Glossary.md +++ b/docs/Glossary.md @@ -66,7 +66,7 @@ The base dispatch function _always_ synchronously sends an action to the store's ## Action Creator ```js -type ActionCreator = (...args: any) => Action | AsyncAction +type ActionCreator = (...args: P) => Action | AsyncAction ``` An _action creator_ is, quite simply, a function that creates an action. Do not confuse the two terms—again, an action is a payload of information, and an action creator is a factory that creates an action. diff --git a/src/types/actions.ts b/src/types/actions.ts index 75215ed7af..7446886922 100644 --- a/src/types/actions.ts +++ b/src/types/actions.ts @@ -49,13 +49,13 @@ export interface AnyAction extends Action { * * @template A Returned action type. */ -export interface ActionCreator { - (...args: any[]): A +export interface ActionCreator { + (...args: P): A } /** * Object whose values are action creator functions. */ -export interface ActionCreatorsMapObject { - [key: string]: ActionCreator +export interface ActionCreatorsMapObject { + [key: string]: ActionCreator } diff --git a/test/typescript/actionCreators.ts b/test/typescript/actionCreators.ts index f7a15bcd75..3c77409cf6 100644 --- a/test/typescript/actionCreators.ts +++ b/test/typescript/actionCreators.ts @@ -10,7 +10,7 @@ interface AddTodoAction extends Action { text: string } -const addTodo: ActionCreator = (text: string) => ({ +const addTodo: ActionCreator = text => ({ type: 'ADD_TODO', text }) @@ -19,7 +19,7 @@ const addTodoAction: AddTodoAction = addTodo('test') type AddTodoThunk = (dispatch: Dispatch) => AddTodoAction -const addTodoViaThunk: ActionCreator = (text: string) => ( +const addTodoViaThunk: ActionCreator = text => ( dispatch: Dispatch ) => ({ type: 'ADD_TODO', @@ -33,8 +33,8 @@ const boundAddTodo = bindActionCreators(addTodo, dispatch) const dispatchedAddTodoAction: AddTodoAction = boundAddTodo('test') const boundAddTodoViaThunk = bindActionCreators< - ActionCreator, - ActionCreator + ActionCreator, + ActionCreator >(addTodoViaThunk, dispatch) const dispatchedAddTodoViaThunkAction: AddTodoAction = boundAddTodoViaThunk( @@ -48,11 +48,11 @@ const otherDispatchedAddTodoAction: AddTodoAction = boundActionCreators.addTodo( ) interface M extends ActionCreatorsMapObject { - addTodoViaThunk: ActionCreator + addTodoViaThunk: ActionCreator } interface N extends ActionCreatorsMapObject { - addTodoViaThunk: ActionCreator + addTodoViaThunk: ActionCreator } const boundActionCreators2 = bindActionCreators(