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

后端 未结 2 1991
梦谈多话
梦谈多话 2021-01-04 10:50

After package updates, I suddenly get weird typescript errors:

[tsl] ERROR in C:..\\UI\\src\\sagas.ts(40,21) TS2769: No overload match

2条回答
  •  旧巷少年郎
    2021-01-04 11:33

    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

提交回复
热议问题