Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
type SafePromise = Promise<number> & { __linterBrands?: string };
declare function returnsSafePromiseIntersection(): SafePromise & {};
returnsSafePromiseIntersection();
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/no-floating-promises": [
"error",
{
"allowForKnownSafePromises": [
{
"from": "file",
"name": "SafePromise"
}
]
}
]
}
}
tsconfig
Expected Result
Since SafePromise
was marked in allowForKnownSafePromises
, intersection types such as SafePromise & {}
should be allowed for it.
Actual Result
The intersection type is considered a wholly new type, so is still reported on.
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator. 5:1 - 5:34
Additional Info
The seemingly-unnecessary & {}
is just to make a minimum reproduction. A full example in production would be Fastify's register
method returning FastifyInstance<...> & SafePromiseLike<undefined>
per fastify/fastify#5506 (comment).
Note that no-floating-promises
is using the shared TypeOrValueSpecifier
logic. This issue only uses no-floating-promises
as a canonical example for why I think we should modify the shared logic. There's no way I can tell to account for Fastify's register()
returning an intersection type without fixing this.
More full repro: https://github.com/JoshuaKGoldberg/repros/tree/fastify-no-floating-promises-repros
💖