Skip to content

Commit

Permalink
fix(eslint-plugin): [explicit-function-return-type] Fix obj setter prop
Browse files Browse the repository at this point in the history
Fixes #525
  • Loading branch information
bradzacher committed May 13, 2019
1 parent 1a0e60b commit 8c8497c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Expand Up @@ -65,7 +65,8 @@ export default util.createRule<Options, MessageIds>({
function isSetter(node: TSESTree.Node | undefined): boolean {
return (
!!node &&
node.type === AST_NODE_TYPES.MethodDefinition &&
(node.type === AST_NODE_TYPES.MethodDefinition ||
node.type === AST_NODE_TYPES.Property) &&
node.kind === 'set'
);
}
Expand Down
Expand Up @@ -169,6 +169,17 @@ class App {
`,
options: [{ allowTypedFunctionExpressions: true }],
},
// https://github.com/typescript-eslint/typescript-eslint/issues/525
{
filename: 'test.ts',
code: `
const myObj = {
set myProp(val) {
this.myProp = val;
},
};
`,
},
],
invalid: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/ts-estree/ts-estree.ts
Expand Up @@ -895,7 +895,7 @@ export interface Property extends BaseNode {
computed: boolean;
method: boolean;
shorthand: boolean;
kind: 'init';
kind: 'init' | 'get' | 'set';
}

export interface RestElement extends BaseNode {
Expand Down

0 comments on commit 8c8497c

Please sign in to comment.