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] allowTypedFunctionExpressions does not work for parameters #679

Closed
davidje13 opened this issue Jul 7, 2019 · 1 comment · Fixed by #680
Labels
enhancement New feature or request has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@davidje13
Copy link

davidje13 commented Jul 7, 2019

Repro

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "sourceType": "module"
  },
  "plugins": ["@typescript-eslint"],
  "rules": {
    "@typescript-eslint/explicit-function-return-type": ["error", {
      "allowTypedFunctionExpressions": true,
    }]
  }
}
class Accumulator {
  private count: number = 0;

  public accumulate(fn: () => number): void {
    this.count += fn();
  }
}

new Accumulator().accumulate(() => 1);

Expected Result

No warnings; type of () => 1 is inferred from accumulate method signature, due to use of allowTypedFunctionExpressions

Actual Result

error: Missing return type on function (@typescript-eslint/explicit-function-return-type) at foobar/Accumulator.ts:9:30:
   7 | }
   8 | 
>  9 | new Accumulator().accumulate(() => 1);
     |                              ^
  10 | 

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 1.11.0
@typescript-eslint/parser 1.11.0
TypeScript 3.5.2
ESLint 5.16.0
node 12.4.0
npm 6.9.0
@davidje13 davidje13 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jul 7, 2019
@bradzacher bradzacher added enhancement New feature or request has pr there is a PR raised to close this and removed triage Waiting for maintainers to take a look labels Jul 7, 2019
@bradzacher
Copy link
Member

Apparently this wasn't ever added to the implementation. I've added handling for it in #680

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants