Skip to content

[explicit-module-boundary-types] does not respect functions exported within array or object literals #2183

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

Closed
tornewuff opened this issue Jun 7, 2020 · 4 comments · Fixed by #2805
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@tornewuff
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/explicit-module-boundary-types": ["error"]
  }
}
interface Foo {
  f: (x: boolean) => boolean
}

export const a: Foo[] = [
  {
    f: (x) => x,
  },
]

Expected Result

No errors; the export has an explicit type defined for all members.

Actual Result

"Missing return type on function."
"Argument 'x' should be typed."

Additional Info

There are no errors when the structure is simpler:

interface Foo {
  f: (x: boolean) => boolean
}

export const a: Foo = {
  f: (x) => x,
}

behaves as expected.

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 12.18.0
npm 6.14.4
@tornewuff tornewuff added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jun 7, 2020
@bradzacher

This comment has been minimized.

@tornewuff
Copy link
Author

This example still returns the same errors in 3.2.0.

@bradzacher bradzacher reopened this Jun 11, 2020
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Jun 11, 2020
@bradzacher bradzacher changed the title [explicit-module-boundary-types] explicit function type not seen inside an array [explicit-module-boundary-types] does not respect functions exported within array or object literals Jun 15, 2020
@essenmitsosse
Copy link

Just incase someone else stumbles upon this, the same problem occurs in object literals. Here as an example:

interface Foo {
    interfaceOuter: {
        interfaceInner: (input: number) => number;
    };
}

export const foo: Foo = {
    interfaceOuter: {
        interfaceInner: (input) => (input),
    },
};

@EtherealData

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants