Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I havesearched for related issues and found none that match my proposal.
- I have searched thecurrent rule list and found no rules that match my proposal.
- I haveread the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/no-floating-promises
Description
As of#8433 ->#9263,no-floating-promises
has acheckThenables
option (enabled by default as of v8) that stops it from flagging anything that's not explicitly aPromise
type. That means the rule won't flag something that's explicitly marked as typePromiseLike
(rather thanPromise
) without explicitly enablingcheckThenables
.
Coming out of conversation with@jakebailey:PromiseLike
does semantically indicate a value is intended to be usedlike aPromise
. That's different from something that coincidentally has a.then()
which can be used withawait
(🤯).
Proposal: should we have the rulealso check forPromiseLike
, in addition toPromise
?
Fail
declarefunctioncreateThenable():PromiseLike<void>;createThenable();
Pass
declarefunctioncreateThenable():{then(a:()=>void,b:()=>void):void}createThenable();
Additional Info
I'm in favor of this personally, for the stated reasoning.
In terms of whether this would be a breaking change: it almost feels like abugfix rather than afeature?PromiseLike
is quite rare in real-world usage. If this is accepted, I'd also be in favor of landing it in a minor version rather than a major.
💖