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

Using async/await based iterators triggers @typescript-eslint/no-misused-promises #1979

Closed
aderant-smcd opened this issue Jul 16, 2024 · 1 comment

Comments

@aderant-smcd
Copy link

aderant-smcd commented Jul 16, 2024

According to this issue: #1386 all the functions in the library support both the oldschool callback based approach and async await via needing the async keyword on passed in iterators + internally the library checking that the passed in function is of type/tagged as AsyncFunction.

This all works fine at runtime, but the iterator types exported from the library (AsyncIterator, AsyncForEachIterator etc...) are still all typed as just returning 'void'. This clashes with the @typescript-eslint/no-misused-promise rule (part of @typescript-eslint/recommended-requiring-type-checking - https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) that tries to flag when you're passing an async function as a parameter to something that doesn't actually expect one and therefore isn't likely to await it or handle errors.

I believe this issue could be fixed by just changing the expected all of the Iterator types to be unions of the void returning version + the Promise<void> returning version to correctly match supported usage?

What version of async are you using?
3.2.5

@aearly
Copy link
Collaborator

aearly commented Jul 16, 2024

This project doesn't maintain the types. Open an issue/PR with https://github.com/DefinitelyTyped/DefinitelyTyped.

@aearly aearly closed this as completed Jul 16, 2024
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

No branches or pull requests

2 participants