Skip to content

[explicit-function-return-type]false positives for functions types #327

Closed
@ghost

Description

When defining functions through the arrow syntax, the return type is defined in the type, not in the return itself.

The small example isn't the most useful piece of code, but it's mainly an issue when using FunctionComponents from react (They're the way forward, so that's only going to be more painful in the future) or any library defining function interfaces really.

const Foo: (n: number) => number = (n) => 2 * n; // This errors but really shouldn't

interface IFoo {
  (n: number): number;
}

const Foo: IFoo = n => n * 2; // Same thing, shouldn't error

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions