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 default class PCancelable<T> implements PromiseLike<T> {
private readonly _promise: Promise<T>;
constructor() {
this._promise = new Promise(() => { });
}
then<TResult1 = T, TResult2 = never>(
onFulfilled?:
| ((value: T) => TResult1 | PromiseLike<TResult1>)
| undefined
| null,
onRejected?:
| ((reason: unknown) => TResult2 | PromiseLike<TResult2>)
| undefined
| null,
): Promise<TResult1 | TResult2> {
return this._promise.then(onFulfilled, onRejected);
}
catch<TResult>(
onRejected?:
| ((reason: unknown) => TResult | PromiseLike<TResult>)
| undefined
| null,
): Promise<T | TResult> {
return this._promise.catch(onRejected);
}
}
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/promise-function-async": "error"
}
}
tsconfig
Expected Result
export default class PCancelable<T> implements PromiseLike<T> {
private readonly _promise: Promise<T>;
constructor() {
this._promise = new Promise(() => {});
}
async then<TResult1 = T, TResult2 = never>(
onFulfilled?:
| ((value: T) => TResult1 | PromiseLike<TResult1>)
| undefined
| null,
onRejected?:
| ((reason: unknown) => TResult2 | PromiseLike<TResult2>)
| undefined
| null,
): Promise<TResult1 | TResult2> {
return this._promise.then(onFulfilled, onRejected);
}
async catch<TResult>(
onRejected?:
| ((reason: unknown) => TResult | PromiseLike<TResult>)
| undefined
| null,
): Promise<T | TResult> {
return this._promise.catch(onRejected);
}
}
Actual Result
Instead of async catch<TResult>(
, the fixer produces catch async <TResult>(
which is invalid syntax.
Additional Info
No response
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.38.1 |
@typescript-eslint/parser |
5.38.1 |
TypeScript |
4.8.3 |
ESLint |
8.15.0 |
node |
web |