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-module-boundary-types] Complains about higher order functions that are not directly typed #2173

Closed
essenmitsosse opened this issue Jun 4, 2020 · 0 comments · Fixed by #2176
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@essenmitsosse
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/explicit-function-return-type": [2, {"allowExpressions": true}],
    "@typescript-eslint/explicit-module-boundary-types": [2]
  }
}
export function foo(): (n: number) => (m: number) => string {
    return function(n) {
            return function(m) {  return String(n+m) }
    }
}

export const foo = 
    (): (n: number) => (m: number) => string => 
        (n) => 
            (m) => String(n+m)

export const bar: () => (n: number) => string = 
    () => 
        (n) => String(n)

type Buz = () => (n: number) => string 

export const buz: Buz = 
    () => 
        (n) => String(n)

Expected Result

Shouldn't give an error for any function where the return type is in any way explicitly typed.

Actual Result

Throws errors, for anything that is more then one function deep into a higher order return type. So either higher order functions 3-levels deep or higher order functions, where the whole function is typed instead of just the return type of the top level higher order function.

Missing return type on function. eslint(@typescript-eslint/explicit-module-boundary-types)
Argument 'm' should be typed. eslint(@typescript-eslint/explicit-module-boundary-types)

Missing return type on function. eslint(@typescript-eslint/explicit-module-boundary-types)
Argument 'n' should be typed. eslint(@typescript-eslint/explicit-module-boundary-types)

Additional Info

Reproduction repo: https://github.com/essenmitsosse/typescript-eslint-explicit-module-boundary-types

Thanks by the way for so quickly fixing the first issue.

Issue also appears in 3.1.1-alpha.4. So it isn't fixed by #2169

Versions

package version
@typescript-eslint/eslint-plugin 3.1.0
@typescript-eslint/parser 3.1.0
TypeScript 3.9.3
ESLint 7.1.0
node 13.14.0
npm 6.14.4
@essenmitsosse essenmitsosse added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jun 4, 2020
@essenmitsosse essenmitsosse changed the title [explicit-module-boundary-types] Complains about inner function expressions in arrow functions [explicit-module-boundary-types] Complains about higher order functions that are not directly typed Jun 4, 2020
@bradzacher bradzacher added bug Something isn't working has pr there is a PR raised to close this and removed triage Waiting for maintainers to take a look labels Jun 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working 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