Skip to content

Commit

Permalink
no-unsafe-any: Allow declare global {} (palantir#2839)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-hanson authored and adidahiya committed May 31, 2017
1 parent 9f6588e commit 5251926
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rules/noUnsafeAnyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ function walk(ctx: Lint.WalkContext<void>, checker: ts.TypeChecker): void {
break;
}

case ts.SyntaxKind.ModuleDeclaration: {
// In `declare global { ... }`, don't mark `global` as unsafe any.
const { body } = node as ts.ModuleDeclaration;
if (body !== undefined) { cb(body); }
return;
}

default:
if (!(isExpression(node) && check())) {
return ts.forEachChild(node, cb);
Expand Down
2 changes: 2 additions & 0 deletions test/rules/no-unsafe-any/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ switch (x.y) {
break;
}

declare global {}

[0]: Unsafe use of expression of type 'any'.

0 comments on commit 5251926

Please sign in to comment.