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

AsyncReturnType doesn't work #93

Closed
UberMouse opened this issue Mar 10, 2020 · 2 comments · Fixed by #96
Closed

AsyncReturnType doesn't work #93

UberMouse opened this issue Mar 10, 2020 · 2 comments · Fixed by #96

Comments

@UberMouse
Copy link

I'm not sure how AsyncReturnType is supposed to work. If I try it with a basic async function, that takes a string argument & returns it, I get a type error.

Type '(bar: string) => Promise' does not satisfy the constraint 'AsyncFunction'.
Types of parameters 'bar' and 'args' are incompatible.
Type 'unknown' is not assignable to type 'string'

I've set up a Codesandbox that demonstrates this. I'm not sure what Typescript version it's using, it's not listed in the dependencies, but I am getting it with TS v3.8.2 in my local project.

I'm not sure if there is a specific reason not to use any here, but replacing ...args: unknown[] with ...args: any[] in the AsyncFunction definition resolves the error.

@sindresorhus
Copy link
Owner

// @resynth1943

@resynth1943
Copy link
Contributor

Ahhh. I know exactly what this is.

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

Successfully merging a pull request may close this issue.

3 participants