Skip to content

Commit

Permalink
no-accessor-recursion: avoid crash on abstract accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff committed Nov 29, 2017
1 parent d176055 commit 99ee15e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/noAccessorRecursionRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function walk(ctx: Lint.WalkContext<void>) {
let name: string | undefined;

return ctx.sourceFile.statements.forEach(function cb(node: ts.Node): any {
if (isAccessorDeclaration(node)) {
if (isAccessorDeclaration(node) && node.body !== undefined) {
const before = name;
name = getPropertyName(node.name);
node.body.statements.forEach(cb);
Expand Down
9 changes: 9 additions & 0 deletions test/rules/no-accessor-recursion/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,13 @@ obj = {
}
}

abstract class MyClass {
abstract get prop(): string;

set prop(v: string) {
this.prop = v;
~~~~~~~~~ [fail]
}
}

[fail]: accessor recursion is not allowed

0 comments on commit 99ee15e

Please sign in to comment.