Skip to content

Typescript: createAsyncThunk, Expected 0 arguments, but got 1 #968

Closed
@ViaxCo

Description

@ViaxCo

Working on a regular JS project in VSCode which uses Typescript to check the files, using createAsyncThunk with an argument causes type errors:

export const addPost = createAsyncThunk("posts/addPost", async post => {});
// somewhere else...
dispatch(addPost(post))

Type error: Expected 0 arguments, but got 1

I understand that the argument in the payloadCreator is typed as void by default and if this was a regular TS project, I could've easily added a type for the post or even typed it as any, but seeing as that is not possible, I would be grateful for a JS solution. I don't seem to be able to extend types either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions