Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise support on types for useRequestPreSend #158

Closed
larrifax opened this issue Mar 23, 2021 · 2 comments · Fixed by #159
Closed

Promise support on types for useRequestPreSend #158

larrifax opened this issue Mar 23, 2021 · 2 comments · Fixed by #159
Assignees
Labels

Comments

@larrifax
Copy link

Describe the bug
The dynamic parameters guide states that:

The handler may return the response immediately or as a promise which resolves to the response

This is not reflected in the Typescript types for useRequestPreSend defined here

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to use an async function in useRequestPreSend
  2. Observe Typescript error stating that the async function is not assignable to the parameter for useRequestPreSend

Expected behavior
No Typescript errors, as async functions are allowed.

Versions
0.11.3 (and earlier)

Code
The following Typescript type definition could work:

type UseRequestPreSendResponse = { items?: BatchItem[]; options?: CreateOptions }

export const useRequestPreSend: (cb: (data: PreSendData) => UseRequestPreSendResponse | Promise<UseRequestPreSendResponse>) => void;
@larrifax
Copy link
Author

Thanks! 🎉

@yoavniran
Copy link
Collaborator

thanks @larrifax - 0.11.4 is now published with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants