diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/tslint/lib/rules/noEmptyInterfaceRule.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
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 + } +} |