Recently, I made the switch from TypeScript 4.1.2 to 4.3.2 with Rematch integration. Here are the Rematch packages in use:
- "@rematch/core": "2.0.1"
- "@rematch/select": "3.0.1"
After the upgrade, a TypeScript error popped up stating: Type never
has no call signatures.
Upon investigating the third-party code, I discovered that RematchDispatch returns a never
type when both a reducer and an effect within a model share the same name.
For instance:
export const myModel = createModel<RootModel>()({
state: { ... },
reducers: {
myReducer(state, payload: string) { ... }
},
effects: dispatch => ({
myReducer(payload: string, rootState) { ... }
}
}
The type
RematchDispatch<RootModel>['myModel']['myReducer']
will be 'never', preventing me from using useDispatch in a React component due to the aforementioned TypeScript error.
Consulting the documentation at , I came across this note:
Effects functions that share a name with a reducer are called after their reducer counterpart.
This behavior was functional before the TypeScript update, hinting at a compatibility issue between Rematch and TypeScript.
Could you provide guidance on resolving this error? Any insight into where I may have gone wrong would be greatly appreciated.
Thank you in advance!