Skip to content

Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void' #81

Open
@Vanuan

Description

@Vanuan

Here's a rough example:

// actions.ts
import actionCreatorFactory from 'typescript-fsa';
const actionCreator = actionCreatorFactory('tasks');
export const allDone = actionCreator('MARK_ALL_DONE');
export const markDone = actionCreator<number>('MARK_DONE');

// Tasks.tsx
interface ITasksProps = {
  allDone: () => void;
  markDone: (taskId: number) => void;
}
...

// TasksContainer.tsx
import Tasks from './Tasks'
import { allDone, markDone } from './actions';
...
const mapDispatchToProps = {
  allDone,
  markDone,
};

connect(null, mapDispatchToProps)(Tasks);

Here's an error:

Type 'ActionCreator<void>' is not assignable to type '() => void'.  TS2345

To fix it, I have to change this:

  allDone: () => void;

To this:

  allDone: (payload: void) => void;

Which is stupid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions