piotrwitek/typesafe-actions

action property type broken with @types/react-redux 6.0.0 + Redux 4 + React Redux 5.0.20 #42

changLiuUNSW posted onGitHub

Version: Redux 4 + React Redux 5.0.20 + typesafe-actions 2.0.2+ types/react-redux 6.0.0

For example:

todoAction:

const load = createAction("[Todo] Load Todo Item");

Container:

export interface Props {
  load: () => void;
}

const TodoContainer = ({load}: Props) => {
  return (
    <div>
      <button onClick={load}>load item</button>
    </div>
  );
};

export default  connect(null, {
  load: todoAction.load
})(TodoContainer);

Error:

[ts]
Argument of type '({ load }: Props) => Element' is not assignable to parameter of type 'ComponentType<Shared<{ items: Todo[];
 loading: boolean; } & { load: () => { type: "[Todo] Load To...'.
  Type '({ load }: Props) => Element' is not assignable to type 'StatelessComponent<Shared<{ items: Todo[]; loading: boolean; } & { load: () => { type: "[Todo] Lo...'.
    Types of parameters '__0' and 'props' are incompatible.
      Type 'Shared<{ items: Todo[]; loading: boolean; } & { load: () => { type: "[Todo] Load Todo Item"; }; }...' is not assignable to type 'Props'.
        Property 'load' is optional in type 'Shared<{ items: Todo[]; loading: boolean; } & { load: () => { type: "[Todo] Load Todo Item"; }; }...' but required in type 'Props'.

Fund this Issue

Rewarded pull request

Recent activities

piotrwitek was rewarded for piotrwitek/typesafe-actions# 42
over 6 years ago
piotrwitek submitted an output to  piotrwitek/ typesafe-actions# 42
over 6 years ago