fix(59825): getNavigationTree crash on invalid class merge and function merge with expando members (#60152)

This commit is contained in:
Oleksandr T. 2024-10-07 22:58:15 +03:00 committed by GitHub
parent 20f67d791c
commit 009b3ffdda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -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);
}

View File

@ -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"
}
]
});