Bug: [no-confusing-void-expression] autofix produces TS2355 when the declared return type is `unknown`
Author: nazsatsCreated Aug 25, 2026Updated Sep 24, 2026
Labelsbugpackage: eslint-pluginaccepting prs
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.
- If I used AI assistance to prepare this issue, I have reviewed and followed the AI Contribution Policy.
Playground Link
Repro Code
(): unknown => console.log('foo');ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/no-confusing-void-expression": ["error"],
},
};tsconfig
{
"compilerOptions": {
"strict": true
}
}Expected Result
- the rule here is defining as the arrow does return a void expression.
- the autofix is not, because the fixed output no longer compiles
- when the fix would break the code, the rule already knows to withhold it: that
is what
canFixis for, and what #7674 added it for. - so the expectation is no autofix offered in this case, same as the conditionally-void ternary cases
Actual Result
The facts, again in your own words:
- reported:
Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. - autofix produces
(): unknown => { console.log('foo'); }; - that output fails with TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value
Additional Info
Worth including, because these are the parts that make it easy to act on:
It is specific to unknown. Controls with void and any fix cleanly:
(): void => console.log('foo'); -> (): void => { console.log('foo'); }; compiles
(): any => console.log('foo'); -> (): any => { console.log('foo'); }; compiles
(): unknown => console.log('foo');-> (): unknown => { console.log('foo'); }; TS2355Three shapes, same cause. All three are already invalid fixtures in
no-confusing-void-expression.test.ts:
(): unknown => console.log('foo');
type Foo = unknown;
(): Foo => console.log();
function test(): unknown {
return console.log();
}The alias case matters: the check has to resolve the annotation's type through
the checker, not match the unknown keyword in the AST.
Their tests pass anyway, because RuleTester asserts the output string and
never checks that the output compiles.
Versions: eslint 10.9.1, typescript 6.0.3, typescript-eslint 8.68.0
Source: typescript-eslint/typescript-eslint