Skip to content

Commit b8e534a

Browse files
committed
no-unused: don't crash on global augmentation
Fixes: #81
1 parent 5a7b38a commit b8e534a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

rules/noUnusedRule.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ function typeParameterMayBeRequired(parameter: ts.TypeParameterDeclaration, usag
259259
case ts.SyntaxKind.ModuleDeclaration:
260260
if ((<ts.ModuleDeclaration>parent).name.kind !== ts.SyntaxKind.Identifier)
261261
return ts.isExternalModule(parent.getSourceFile());
262+
if (parent.flags & ts.NodeFlags.GlobalAugmentation)
263+
return true;
262264
const variable = usage.get(<ts.Identifier>(<ts.ModuleDeclaration>parent).name)!;
263265
if (!variable.exported)
264266
return variable.inGlobalScope;

test/rules/no-unused/default/type-parameter.ts.lint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ declare module "foo" {
66

77
export default class <T> {}
88
~ [TypeParameter 'T' is unused.]
9+
10+
declare global {
11+
namespace jest {
12+
interface Matchers<R> {
13+
toEqualSomething(argument: string): object;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)