-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Enhancement: [await-thenable] should prohibit using a sync disposable with await using
#10208
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
Comments
Note that the fundamental concern here is that a |
probably makes most sense for this to be in |
await using
await using
await using
await using
@bradzacher function unhandledRejection() {
using _ = {
async [Symbol.dispose]() {
throw new Error('dispose error');
}
}
} It doesn't go in await-thenable, since that's all about unnecessary |
Does the disposable method have a default type definition? If it does then iirc there's another rule that should already catch it. If it doesn't then no-misused-promises would probably be a good fit - iirc it already handles array iteration callbacks. |
After a bit of investigation...
|
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/await-thenable/, https://typescript-eslint.io/rules/no-floating-promises, https://typescript-eslint.io/rules/no-misused-promises
Description
I would like to find a place to lint for providing a sync disposable to an
await using
statement. This relates closely to #8858, so maybe await-thenable is the right place for this check? But it also has concerns very adjacent to no-floating-promises and no-misused-promises, so I'm not sure.Fail
Pass
Additional Info
The promise rejection in
unhandledRejection
cannot be caught, since the[Symbol.dispose]()
method is called, but is not awaited, by anawait using
statement. Only the[Symbol.asyncDispose]()
method is awaited.There's a lot of subtlety here so I've provided a repo to be able to play with variations on this at https://github.com/kirkwaiblinger/typescript-eslint-repro-await-using
The text was updated successfully, but these errors were encountered: