Why this type action is giving me error in typescript?

Viewed 41

I got this action

export const getTodos =
  (url: string): ThunkAction<void, Store, unknown, Action<string>> =>
  async (dispatch) => {
    const response = await fetch(url);
    const data: Todo[] = await response.json();
    dispatch(setTodos(data));
  };

When I try to use it in my component like this.

dispatch(getTodos('https://gettodo.com'));

There is an error indication like this .

Argument of type 'ThunkAction<void, Store<any, AnyAction>, unknown, Action>' is not assignable to parameter of type 'AnyAction'.

Property 'type' is missing in type 'ThunkAction<void, Store<any, AnyAction>, unknown, Action>' but required in type 'AnyAction'.ts(2345)

What am I doing wrong?

0 Answers
Related