Skip to content

ResponseData type doesn't work as I think it should #436

@hendrul

Description

@hendrul

I want to have typing when dispatching (or putting) an action from a saga, something like

const response: ResponseData<typeof fetchTodos> = yield putResolve(fetchTodos())

but response got type any...
Instead my own implementation looks like this

type ResponseData<Request extends (...args: any[]) => RequestAction> = {
  data?: ReturnType<Request> extends RequestAction<infer D> ? D : never
  error?: Error  
  isAborted: boolean
  action: ReturnType<Request>
}

And it type what I expect to return from a request

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions