Skip to content

[explicit-module-boundary-types] expects return type on methods of abstract class setter #2407

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
3 tasks done
ljosberinn opened this issue Aug 20, 2020 · 1 comment · Fixed by #2410
Closed
3 tasks done
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ljosberinn
Copy link

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/explicit-module-boundary-types": "error"
  }
}
export abstract class SomeClass<T> {
  abstract set value(element: T);
}

image

https://github.com/ljosberinn/explicit-module-boundary-types-bug

Expected Result
The rule should never expect a return type of a setter to be declared.

Actual Result

The rule expects a return type which is a compiler error.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 3.9.1
@typescript-eslint/parser 3.9.1
TypeScript 3.9.7
ESLint 7.7.0
node ---
@ljosberinn ljosberinn added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Aug 20, 2020
@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Aug 20, 2020
@bradzacher
Copy link
Member

bradzacher commented Aug 20, 2020

The bug is in this code right here.

function checkEmptyBodyFunctionExpression(
node: TSESTree.TSEmptyBodyFunctionExpression,
): void {
const isConstructor =
node.parent?.type === AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'constructor';
if (!isConstructor && !node.returnType) {
context.report({
node,
messageId: 'missingReturnType',
});
}
checkParameters(node);
}

I didn't even know you could define abstract setters, which is why this code never handled it.

Should be a pretty simple fix, if you want to submit a PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants