Skip to content

Commit

Permalink
fix(eslint-plugin): [explicit-module-boundary-types] ignore functions…
Browse files Browse the repository at this point in the history
… exported within typed object/array literals (#2805)
  • Loading branch information
pvanagtmaal committed Nov 25, 2020
1 parent 32b1b68 commit 73a63ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Expand Up @@ -390,6 +390,10 @@ export default util.createRule<Options, MessageIds>({
function ancestorHasReturnType(node: FunctionNode): boolean {
let ancestor = node.parent;

if (ancestor?.type === AST_NODE_TYPES.Property) {
ancestor = ancestor.value;
}

// if the ancestor is not a return, then this function was not returned at all, so we can exit early
const isReturnStatement =
ancestor?.type === AST_NODE_TYPES.ReturnStatement;
Expand Down
Expand Up @@ -661,6 +661,26 @@ export class A {
b = A;
}
`,
`
interface Foo {
f: (x: boolean) => boolean;
}
export const a: Foo[] = [
{
f: (x: boolean) => x,
},
];
`,
`
interface Foo {
f: (x: boolean) => boolean;
}
export const a: Foo = {
f: (x: boolean) => x,
};
`,
],
invalid: [
{
Expand Down

0 comments on commit 73a63ee

Please sign in to comment.