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

Commit

Permalink
noInferrableTypes: check property declarations. (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
mprobst authored and nchen63 committed Jan 21, 2017
1 parent c2c0054 commit 48b0c59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rules/noInferrableTypesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ class NoInferrableTypesWalker extends Lint.RuleWalker {
super.visitParameterDeclaration(node);
}

private checkDeclaration(node: ts.ParameterDeclaration | ts.VariableDeclaration) {
public visitPropertyDeclaration(node: ts.PropertyDeclaration) {
this.checkDeclaration(node);
super.visitPropertyDeclaration(node);
}

private checkDeclaration(node: ts.ParameterDeclaration | ts.VariableDeclaration | ts.PropertyDeclaration) {
if (node.type != null && node.initializer != null) {
let failure: string | null = null;

Expand Down
4 changes: 4 additions & 0 deletions test/rules/no-inferrable-types/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ let y: boolean = false;
~~~~~~~ [boolean]
let z: string = "foo";
~~~~~~ [string]
class C {
x: number = 1;
~~~~~~ [number]
}

// errors, types are inferrable
function foo (a: number = 5, b: boolean = true, c: string = "bah") { }
Expand Down

0 comments on commit 48b0c59

Please sign in to comment.