agiledigital / typed-redux-saga

An attempt to bring better TypeScript typing to redux-saga.
MIT License
315 stars 33 forks source link

Argument of type 'string' is not assignable to parameter of type 'TakeableChannel<unknown>'. #674

Closed Mohammed-Mounir closed 1 year ago

Mohammed-Mounir commented 1 year ago

dispatching action with payload, produces this typescript error: Argument of type 'string' is not assignable to parameter of type 'TakeableChannel'. .

export default function watchAuth() { yield takeLatest(startAuth.toString(), handleAuthUser); // Argument of type 'string' is not assignable to parameter of type 'TakeableChannel'. }

using: "@reduxjs/toolkit": "^1.8.5", "typed-redux-saga": "^1.5.0",

Mohammed-Mounir commented 1 year ago

Solution:

Import PayloadAction from redux toolkit and pass the payload object definition

function* handleAuthUser({ payload: { fields, isRegister }, }: PayloadAction<{ fields: { [key: string]: string }; isRegister?: boolean }>) { }