diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/noEmptyInterfaceRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/noEmptyInterfaceRule.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js index ae42d72e6..f23f3aade 100644 --- a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js +++ b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js @@ -48,11 +48,20 @@ function walk(ctx) { return ts.forEachChild(ctx.sourceFile, function cb(node) { if (tsutils_1.isInterfaceDeclaration(node) && node.members.length === 0 && - (node.heritageClauses === undefined || - // allow interfaces that extend 2 or more interfaces - node.heritageClauses[0].types.length < 2)) { + (node.heritageClauses === undefined || extendsOneTypeWithoutTypeArguments(node.heritageClauses[0]))) { return ctx.addFailureAtNode(node.name, node.heritageClauses !== undefined ? Rule.FAILURE_STRING_FOR_EXTENDS : Rule.FAILURE_STRING); } return ts.forEachChild(node, cb); }); } +function extendsOneTypeWithoutTypeArguments(_a) { + var types = _a.types; + switch (types.length) { + case 0: + return true; // don't crash on empty extends list + case 1: + return types[0].typeArguments === undefined; // allow interfaces that provide type arguments for the extended type + default: + return false; // allow interfaces extending more than one types + } +} |