Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read 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 a checkThenables
option (enabled by default as of v8) that stops it from flagging anything that's not explicitly a Promise
type. That means the rule won't flag something that's explicitly marked as type PromiseLike
(rather than Promise
) without explicitly enabling checkThenables
.
Coming out of conversation with @jakebailey: PromiseLike
does semantically indicate a value is intended to be used like a Promise
. That's different from something that coincidentally has a .then()
which can be used with await
(🤯).
Proposal: should we have the rule also check for PromiseLike
, in addition to Promise
?
Fail
declare function createThenable(): PromiseLike<void>;
createThenable();
Pass
declare function createThenable(): { 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 a bugfix rather than a feature? 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.
💖