Closed
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
export type PromiseWithResolvers<T> = {
// ...
}
/**
* Userland implementation of [Promise.withResolvers]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers}.
* Once we upgrade to Node 22, we can switch to the builtin.
*/
export function withResolvers<T>(
this: PromiseConstructor | void
): PromiseWithResolvers<T> {
return {
// ...
}
}
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/no-invalid-void-type": "error",
},
};
tsconfig
Expected Result
No error
Actual Result
void is not valid as a constituent in a union type 10:30 - 10:34
Additional Info
This is the only possible way to type an optional this
binding other than function overloads, but function overloads trigger @typescript-eslint/unified-signatures
.