Skip to content

[explicit-function-return-type] Have to type every chain of higher order function  #928

Closed
@lonyele

Description

@lonyele

Playground

While I'm trying to work on #758, I found this behaviour which seems incorrect.
I have an error with below code and to make it silent I had to explicitly type every chain of higher order function.

// with errors
const x = (arg1: string) => {
  const tempVar1 = 'temporary value1';
  const tempVar2 = 'temporary value2';
  return (arg2: number): string => 'foo';
}

// without error(have to explicitly type every chain)
const x = (arg1: string): (arg2: number) => string => {
  const tempVar1 = 'temporary value1';
  const tempVar2 = 'temporary value2';
  return (arg2: number): string => 'foo';
}

It seems like the code is only covering the case that is returning function right away inside of BlockStatement. I think it can be improved so I made a PR #894 Initially I only made a PR but I'm writing this issue for better history tracking.

Aside from this PR, can you review my other PRs too? If you are not satisfied with my implementation, please leave me some comments so that I can apply your feedback. Hope it's not that bad try this time.

Versions

package version
@typescript-eslint/eslint-plugin 2.0.0
@typescript-eslint/parser 2.0.0-alpha.0
TypeScript 3.5.1
ESLint 6.0.0
node 11.15.0
yarn 1.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: 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