[explicit-function-return-type] allowTypedFunctionExpressions
option should be aware of JSX
#7552
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Issue Description
The
explicit-function-return-type
rule has theallowTypedFunctionExpressions
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
pnpm install
pnpm lint
(other package managers will work as well)
(only the first error should be valid)
Versions
@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
The text was updated successfully, but these errors were encountered: