How to repair a 'TS2769: No overload matches this call'

28,100

Solution 1

My colleague eventually taught me a workaround:

  1. Exclude the corresponding action, e.g. takeEvery from the original import statement.
  2. Import all action with as Eff where Eff is an alias.
  3. Define a new constant with the same name as the original action.
import { put, fork, select, call } from 'redux-saga/effects' // <-- modified
import * as Eff from 'redux-saga/effects'  // <-- new

// ... 

const takeEvery: any = Eff.takeEvery;      // <-- new
const takeLatest: any = Eff.takeLatest;    // <-- new

As far as I understand him, the idea is to explicity allow any type.

Edit: I am aware that Facebook (as developer of React) does explicitly state that one should not use inheritance, see https://reactjs.org/docs/composition-vs-inheritance.html

Solution 2

I also met this problem, but I asked my colleague and learned about the following solution:

redux-saga takes TakeableChannel<unknown>. This is an action, so you declare type of loadIds's argument is shape of action like this:

function* loadIds({
   forceReload
}: { 
   type: string;
   forceReload: any; // your forceReload type
}) {
   // your code
}
Share:
28,100
B--rian
Author by

B--rian

During working hours: Risk and IT consultant bridging the gap between technical specialists of different fields and the wider (business) audience. What I like: open source and public understanding of science. Also, designing IT architecture for new challenges (like my own app), simplifying existing IT solutions to make it more user-friendly. By education: Statistical Physicist with a background in complex systems.

Updated on August 04, 2022

Comments