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

https://typescript-eslint.io/play#ts=6.0.2&showAST=ts&fileType=.tsx&code=BQSgXABArgdg1jA9gdxhAvAPggY0TAZ0QBsBTAOmMQHNgByAM0UTpAG4g&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

typescript
(): unknown => console.log('foo');

ESLint Config

javascript
module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-confusing-void-expression": ["error"],
  },
};

tsconfig

jsonc
{
  "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 canFix is 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'); }; TS2355

Three shapes, same cause. All three are already invalid fixtures in no-confusing-void-expression.test.ts:

typescript
(): 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