Skip to content

Commit 009b3ff

Browse files
authored
fix(59825): getNavigationTree crash on invalid class merge and function merge with expando members (#60152)
1 parent 20f67d7 commit 009b3ff

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/services/navigationBar.ts

+1
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ function isSynthesized(node: Node) {
760760
// We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }`
761761
// We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };`
762762
function isOwnChild(n: Node, parent: NavigationBarNode): boolean {
763+
if (n.parent === undefined) return false;
763764
const par = isModuleBlock(n.parent) ? n.parent.parent : n.parent;
764765
return par === parent.node || contains(parent.additionalNodes, par);
765766
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////function Z() { }
4+
////
5+
////Z.foo = 42
6+
////
7+
////class Z { }
8+
9+
verify.navigationTree({
10+
text: "<global>",
11+
kind: "script",
12+
childItems: [
13+
{
14+
text: "Z",
15+
kind: "class",
16+
childItems: [
17+
{
18+
text: "constructor",
19+
kind: "constructor"
20+
},
21+
{
22+
text: "foo"
23+
}
24+
]
25+
},
26+
{
27+
text: "Z",
28+
kind: "class"
29+
}
30+
]
31+
});

0 commit comments

Comments
 (0)