Skip to content

Commit

Permalink
fix(59825): getNavigationTree crash on invalid class merge and functi…
Browse files Browse the repository at this point in the history
…on merge with expando members (#60152)
  • Loading branch information
a-tarasyuk authored Oct 7, 2024
1 parent 20f67d7 commit 009b3ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/services/navigationBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
31 changes: 31 additions & 0 deletions tests/cases/fourslash/navigationBarItemsClass6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference path="fourslash.ts"/>

////function Z() { }
////
////Z.foo = 42
////
////class Z { }

verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "Z",
kind: "class",
childItems: [
{
text: "constructor",
kind: "constructor"
},
{
text: "foo"
}
]
},
{
text: "Z",
kind: "class"
}
]
});

0 comments on commit 009b3ff

Please sign in to comment.