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.
Issue Description
The explicit-function-return-type
rule has the allowTypedFunctionExpressions
option. This option is enabled as part of the default option set for the rule.
This option is meant to allow omitting a return type when it will be enforced during assignment against a LHS type assertion, similar to how omitted argument types will be handled by TypeScript itself. This option should take into account assignment to JSX attributes but does not. Such assignment will be fully enforced by TypeScript JSX handling and is semantically the same as the object-attribute-assignment logic that is also allowed under this option.

As seen in this screenshot from the linked repo, examples 2 and 3 are functionally the same but treated differently by the rule. Example 3 should not be a lint error.
Demo PR with a potential version of this change.
Reproduction Repository Link
https://github.com/merrywhether/return-type
Repro Steps
- clone the repo
pnpm install
pnpm lint
(other package managers will work as well)
% pn lint
> return-type@0.1.0 lint .../return-type
> next lint
./src/pages/index.tsx
15:5 Error: Missing return type on function. @typescript-eslint/explicit-function-return-type
33:22 Error: Missing return type on function. @typescript-eslint/explicit-function-return-type
(only the first error should be valid)
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
6.5.0 |
@typescript-eslint/parser |
6.5.0 |
TypeScript |
5.2.2 |
ESLint |
8.48.0 |
node |
20.3.1 |