diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 6ca2a1804a8..b4c32d566b1 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -760,6 +760,7 @@ function isSynthesized(node: Node) { // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` function isOwnChild(n: Node, parent: NavigationBarNode): boolean { + if (n.parent === undefined) return false; const par = isModuleBlock(n.parent) ? n.parent.parent : n.parent; return par === parent.node || contains(parent.additionalNodes, par); } diff --git a/tests/cases/fourslash/navigationBarItemsClass6.ts b/tests/cases/fourslash/navigationBarItemsClass6.ts new file mode 100644 index 00000000000..7dc7290356d --- /dev/null +++ b/tests/cases/fourslash/navigationBarItemsClass6.ts @@ -0,0 +1,31 @@ +/// + +////function Z() { } +//// +////Z.foo = 42 +//// +////class Z { } + +verify.navigationTree({ + text: "", + kind: "script", + childItems: [ + { + text: "Z", + kind: "class", + childItems: [ + { + text: "constructor", + kind: "constructor" + }, + { + text: "foo" + } + ] + }, + { + text: "Z", + kind: "class" + } + ] +});