-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
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
class Base {
async foo() {
return Promise.resolve(42);
}
}
class Derived extends Base {
override foo() {
return Promise.resolve(2000)
}
}ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/promise-function-async": "error"
}
};tsconfig
Expected Result
The fixer should produce valid TypeScript syntax with the async keyword placed after the override modifier, following TypeScript's correct modifier order.
class Base {
async foo() {
return Promise.resolve(42);
}
}
class Derived extends Base {
override async foo() {
return Promise.resolve(2000)
}
}Actual Result
The fixer generates invalid syntax by placing the async keyword before the override modifier, which violates TypeScript's modifier ordering rules and causes a syntax error.
class Base {
async foo() {
return Promise.resolve(42);
}
}
class Derived extends Base {
async override foo() {
return Promise.resolve(2000)
}
}Additional Info
The root cause is that the fixer's token-skipping logic only handles Keyword type tokens such as public and static, but TypeScript's override is classified as an Identifier token.
This causes the insertion point to be calculated incorrectly, resulting in invalid modifier ordering.
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
{ "compilerOptions": { // ... } }