Skip to content

Commit

Permalink
Fix null reference bug (palantir#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkillian authored Jun 25, 2016
1 parent 4fc600b commit 81b8d7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/typedefRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TypedefWalker extends Lint.RuleWalker {

// If this is an arrow function, it doesn't need to have a typedef on the property declaration
// as the typedefs can be on the function's parameters instead
const performCheck = !(node.initializer.kind === ts.SyntaxKind.ArrowFunction && node.type == null);
const performCheck = !(node.initializer != null && node.initializer.kind === ts.SyntaxKind.ArrowFunction && node.type == null);

if (performCheck) {
this.checkTypeAnnotation(optionName, node.name.getEnd(), node.type, node.name);
Expand Down
7 changes: 7 additions & 0 deletions test/rules/typedef/all/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ someFunc(n => n+1);
~ [expected arrow-parameter: 'n' to have a typedef]
someFunc(n => {});
~ [expected arrow-parameter: 'n' to have a typedef]

class A {
// property w/o an initializer
public foo;
~ [expected member-variable-declaration: 'foo' to have a typedef]
private bar: number;
}

0 comments on commit 81b8d7e

Please sign in to comment.