Skip to content

Commit

Permalink
Skip index signatures in no-shadowed-variable rule (fixes palantir#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
IllusionMH committed Aug 14, 2016
1 parent bd0c45f commit 759be68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rules/noShadowedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class NoShadowedVariableWalker extends Lint.BlockScopeAwareRuleWalker<ScopeInfo,

public visitParameterDeclaration(node: ts.ParameterDeclaration) {
const isSingleParameter = node.name.kind === ts.SyntaxKind.Identifier;
const isIndexSignature = node.parent.kind === ts.SyntaxKind.IndexSignature;

if (isSingleParameter) {
if (isSingleParameter && !isIndexSignature) {
this.handleSingleParameterIdentifier(<ts.Identifier> node.name);
}

Expand Down
5 changes: 5 additions & 0 deletions test/rules/no-shadowed-variable/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,8 @@ function testParameterDestructuring(
function testSimpleBlockVar() {
const simpleBlockVar = 4
}

interface IFoo {
[i: string]: any;
[i: number]: any;
}

0 comments on commit 759be68

Please sign in to comment.