I just upgraded from typescript 4.1.2 to 4.3.2 using Rematch. These rematch packages are used:
- "@rematch/core": "2.0.1"
- "@rematch/select": "3.0.1"
and I faced a typescript error: Type never
has no call signatures.
I looked into the 3rd parties' code and found that RematchDispatch gives never
type when I have a reducer and an effect in a particular model with the same name.
For example:
export const myModel = createModel<RootModel>()({
state: { ... },
reducers: {
myReducer(state, payload: string) { ... }
},
effects: dispatch => ({
myReducer(payload: string, rootState) { ... }
}
}
and RematchDispatch<RootModel>['myModel']['myReducer']
type will give 'never' type so for example I cannot call this via useDispatch in a react component because of the above-mentioned typescript error.
I also checked the documentation: https://rematchjs.org/docs/api-reference/models and found this
Effects functions that share a name with a reducer are called after their reducer counterpart.
This seems to be a valid case and it worked in my project until this typescript upgrade so this issue might be related to the Rematch and Typescript mix.
Could you please help me with this issue? What did I do in the wrong way?
Thanks in advance!