diff --git a/src/rules/noInferrableTypesRule.ts b/src/rules/noInferrableTypesRule.ts index 617724d2a72..1a5c8c6b32c 100644 --- a/src/rules/noInferrableTypesRule.ts +++ b/src/rules/noInferrableTypesRule.ts @@ -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; diff --git a/test/rules/no-inferrable-types/default/test.ts.lint b/test/rules/no-inferrable-types/default/test.ts.lint index 37553cfd3ba..22dbc0281df 100644 --- a/test/rules/no-inferrable-types/default/test.ts.lint +++ b/test/rules/no-inferrable-types/default/test.ts.lint @@ -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") { }