Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Mar 1, 2019 · 1 comment
Closed

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

ghost opened this issue Mar 1, 2019 · 1 comment
Labels
duplicate This issue or pull request already exists enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ghost
Copy link

ghost commented Mar 1, 2019

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
@ghost ghost added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 1, 2019
@ghost ghost changed the title [explicit-function-return-type]false positives for functions typed with Function [explicit-function-return-type]false positives for functions types Mar 1, 2019
@bradzacher bradzacher added duplicate This issue or pull request already exists enhancement: plugin rule option New rule option for an existing eslint-plugin rule and removed triage Waiting for maintainers to take a look labels Mar 4, 2019
@bradzacher
Copy link
Member

Duplicate of #149

@bradzacher bradzacher marked this as a duplicate of #149 Mar 4, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

1 participant