Bug: [prefer-arrow-callback] invalid report on a function expression with a TS `this` parameter
Author: bradzacherCreated Jul 27, 2026Updated Sep 28, 2026
Labelsbugrepro:yesStale
Environment
ESLint Playground
What parser are you using?
@typescript-eslint/parser
What did you do?
Playground Code
/*eslint prefer-arrow-callback: ["error"]*/
function acceptsCb(cb) {}
class Foo {}
acceptsCb(function (this: Foo) {})
ESLint Configuration
Tap to see full configimport { defineConfig } from "eslint/config";
import tsParser from "@typescript-eslint/parser";
export default defineConfig([
{
"languageOptions": {
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"parser": tsParser
}
}
]);ESLint Output
7:11 Unexpected function expression. (prefer-arrow-callback)What did you expect to happen?
No report because arrow functions cannot define a this: T parameter.
The autofix creates broken code by fixing the line to acceptsCb((this: Foo) => {}) which is a TS semantic error and a syntax error in most TS parsers.
The rule should ignore function expressions that define a TS this: T parameter.
What actually happened?
7:11 Unexpected function expression. (prefer-arrow-callback)
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
AI acknowledgment
- I did not use AI to generate this issue report.
- (If the above is not checked) I have reviewed the AI-generated content before submitting.
Additional comments
No response
Source: eslint/eslint