Fix bug: In findAllReferences, don't crash on static method missing body (#24814)

This commit is contained in:
Andy 2018-06-11 08:43:17 -07:00 committed by GitHub
parent 3f8661b2de
commit 986532d36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -1035,14 +1035,16 @@ namespace ts.FindAllReferences.Core {
if (!(isMethodOrAccessor(member) && hasModifier(member, ModifierFlags.Static))) {
continue;
}
member.body!.forEachChild(function cb(node) {
if (node.kind === SyntaxKind.ThisKeyword) {
addRef(node);
}
else if (!isFunctionLike(node)) {
node.forEachChild(cb);
}
});
if (member.body) {
member.body.forEachChild(function cb(node) {
if (node.kind === SyntaxKind.ThisKeyword) {
addRef(node);
}
else if (!isFunctionLike(node)) {
node.forEachChild(cb);
}
});
}
}
}

View File

@ -0,0 +1,7 @@
/// <reference path="fourslash.ts" />
////declare class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {
//// static m(): void;
////}
verify.singleReferenceGroup("class C");