Skip to content

Commit

Permalink
no-unused: don't crash on global augmentation
Browse files Browse the repository at this point in the history
Fixes: #81
  • Loading branch information
ajafff committed Jul 4, 2018
1 parent 5a7b38a commit b8e534a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rules/noUnusedRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ function typeParameterMayBeRequired(parameter: ts.TypeParameterDeclaration, usag
case ts.SyntaxKind.ModuleDeclaration:
if ((<ts.ModuleDeclaration>parent).name.kind !== ts.SyntaxKind.Identifier)
return ts.isExternalModule(parent.getSourceFile());
if (parent.flags & ts.NodeFlags.GlobalAugmentation)
return true;
const variable = usage.get(<ts.Identifier>(<ts.ModuleDeclaration>parent).name)!;
if (!variable.exported)
return variable.inGlobalScope;
Expand Down
8 changes: 8 additions & 0 deletions test/rules/no-unused/default/type-parameter.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ declare module "foo" {

export default class <T> {}
~ [TypeParameter 'T' is unused.]

declare global {
namespace jest {
interface Matchers<R> {
toEqualSomething(argument: string): object;
}
}
}

0 comments on commit b8e534a

Please sign in to comment.