Fix bug: handle missing symbol.parent for non-accessible symbol (#21834)

This commit is contained in:
Andy 2018-02-09 13:48:40 -08:00 committed by GitHub
parent 6dd88b39d5
commit aa1ebda6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -712,7 +712,7 @@ namespace ts.Completions {
function getFirstSymbolInChain(symbol: Symbol, enclosingDeclaration: Node, checker: TypeChecker): Symbol | undefined {
const chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ SymbolFlags.All, /*useOnlyExternalAliasing*/ false);
if (chain) return first(chain);
return isModuleSymbol(symbol.parent) ? symbol : symbol.parent && getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker);
return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker));
}
function isModuleSymbol(symbol: Symbol): boolean {

View File

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////function f() {
//// class C {}
//// return (c: C) => void;
////}
////f()(new /**/);
goTo.marker("");
verify.not.completionListContains("C"); // Not accessible