Skip to content

Commit aa1ebda

Browse files
author
Andy
authored
Fix bug: handle missing symbol.parent for non-accessible symbol (#21834)
1 parent 6dd88b3 commit aa1ebda

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/services/completions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ namespace ts.Completions {
712712
function getFirstSymbolInChain(symbol: Symbol, enclosingDeclaration: Node, checker: TypeChecker): Symbol | undefined {
713713
const chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ SymbolFlags.All, /*useOnlyExternalAliasing*/ false);
714714
if (chain) return first(chain);
715-
return isModuleSymbol(symbol.parent) ? symbol : symbol.parent && getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker);
715+
return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker));
716716
}
717717

718718
function isModuleSymbol(symbol: Symbol): boolean {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////function f() {
4+
//// class C {}
5+
//// return (c: C) => void;
6+
////}
7+
////f()(new /**/);
8+
9+
goTo.marker("");
10+
verify.not.completionListContains("C"); // Not accessible

0 commit comments

Comments
 (0)