Skip to content

[bug: typescript] ActionCreator lose it's arguments type #3455

Open
@dabuside

Description

@dabuside

What is the current behavior?

const addTodo: ActionCreator<AddTodoAction> = (text: string) => ({
type: 'ADD_TODO',
text
})
const addTodoAction: AddTodoAction = addTodo('test')

We declare the addTodo function that accepts one string argument text,
but we could pass any argument to it.

const addTodoAction: AddTodoAction = addTodo(false, 0, null);
👆👆👆 //no ts error!

There may be a problem (...args: any[])

redux/index.d.ts

Lines 440 to 442 in c676a25

export interface ActionCreator<A> {
(...args: any[]): A
}

What is the expected behavior?

Raise a type error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions