Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #653 from palantir/fix-shadowed
Browse files Browse the repository at this point in the history
Don't check parameters in call signatures
  • Loading branch information
adidahiya committed Sep 16, 2015
2 parents 5aaaff7 + ea3fddf commit b93535b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/tslint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare module Lint {
protected visitBlock(node: ts.Block): void;
protected visitBreakStatement(node: ts.BreakOrContinueStatement): void;
protected visitCallExpression(node: ts.CallExpression): void;
protected visitCallSignature(node: ts.SignatureDeclaration): void;
protected visitCaseClause(node: ts.CaseClause): void;
protected visitClassDeclaration(node: ts.ClassDeclaration): void;
protected visitCatchClause(node: ts.CatchClause): void;
Expand Down
8 changes: 8 additions & 0 deletions src/language/walker/syntaxWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ module Lint {
this.walkChildren(node);
}

protected visitCallSignature(node: ts.SignatureDeclaration) {
this.walkChildren(node);
}

protected visitCaseClause(node: ts.CaseClause) {
this.walkChildren(node);
}
Expand Down Expand Up @@ -310,6 +314,10 @@ module Lint {
this.visitCallExpression(<ts.CallExpression> node);
break;

case ts.SyntaxKind.CallSignature:
this.visitCallSignature(<ts.SignatureDeclaration> node);
break;

case ts.SyntaxKind.CaseClause:
this.visitCaseClause(<ts.CaseClause> node);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/rules/noShadowedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class NoShadowedVariableWalker extends Lint.BlockScopeAwareRuleWalker<ScopeInfo,
this.visitBlock(node.block);
}

public visitCallSignature(node: ts.SignatureDeclaration) {
// don't call super, we don't need to check parameter names in call signatures
}

public visitFunctionType(node: ts.FunctionOrConstructorTypeNode) {
// don't call super, we don't need to check names in function types
}
Expand Down
5 changes: 5 additions & 0 deletions test/files/rules/no-shadowed-variable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@ interface FalsePositive3 {
specular: (pos: number) => number;
pos: number;
}

interface FalsePositive4<T, TResult> {
(parameters: T, runSynchonous: boolean): TResult;
(parameters: T, callback: (error: Error, result: TResult) => void): void;
}

0 comments on commit b93535b

Please sign in to comment.