Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Allow empty interfaces with 2 or more parents #2070

Merged
merged 1 commit into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/rules/noEmptyInterfaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ export class Rule extends Lint.Rules.AbstractRule {

class Walker extends Lint.RuleWalker {
public visitInterfaceDeclaration(node: ts.InterfaceDeclaration) {
if (node.members.length === 0) {
if (node.members.length === 0 &&
(node.heritageClauses === undefined ||
node.heritageClauses[0].types === undefined ||
// allow interfaces that extend 2 or more interfaces
node.heritageClauses[0].types!.length < 2)) {
this.addFailureAtNode(node.name, node.heritageClauses ? Rule.FAILURE_STRING_FOR_EXTENDS : Rule.FAILURE_STRING);
}
super.visitInterfaceDeclaration(node);
}
}
5 changes: 5 additions & 0 deletions test/rules/no-empty-interface/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ interface J extends I { }
~ [An interface declaring no members is equivalent to its supertype.]

interface K { x: number; }

interface L extends J, K {} // extending more than one interface is ok, as it can be used instead of intersection types

interface M extends {} // don't crash on empty extends list
~ [An interface declaring no members is equivalent to its supertype.]