diff --git a/src/rules/typedefRule.ts b/src/rules/typedefRule.ts index 876f7633bab..2587f73840f 100644 --- a/src/rules/typedefRule.ts +++ b/src/rules/typedefRule.ts @@ -185,7 +185,7 @@ class TypedefWalker extends Lint.RuleWalker { // catch statements will be the parent of the variable declaration // for-in/for-of loops will be the gradparent of the variable declaration if (node.parent != null && node.parent.parent != null - && node.parent.parent.kind !== ts.SyntaxKind.CatchClause + && (node as ts.Node).parent.kind !== ts.SyntaxKind.CatchClause && node.parent.parent.kind !== ts.SyntaxKind.ForInStatement && node.parent.parent.kind !== ts.SyntaxKind.ForOfStatement) { this.checkTypeAnnotation("variable-declaration", node.name.getEnd(), node.type, node.name); diff --git a/test/rules/typedef/all/test.ts.lint b/test/rules/typedef/all/test.ts.lint index 3e026023f74..b2991703b9c 100644 --- a/test/rules/typedef/all/test.ts.lint +++ b/test/rules/typedef/all/test.ts.lint @@ -1,3 +1,8 @@ +// should not error with missing exception type +try { +} catch (e) { +} + var NoTypeObjectLiteralWithPropertyGetter = { ~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] Prop: "some property",