Fix crash on completion in jsdoc namepath (#39347)

contextToken may be undefined, so the isAssertionExpression call in
filterGlobalCompletion needs to check for undefined.
This commit is contained in:
Nathan Shively-Sanders
2020-06-30 15:53:13 -07:00
committed by GitHub
parent 0f9d4c78d4
commit df5981319f
2 changed files with 16 additions and 5 deletions

View File

@@ -1464,7 +1464,7 @@ namespace ts.Completions {
function filterGlobalCompletion(symbols: Symbol[]): void {
const isTypeOnly = isTypeOnlyCompletion();
if (isTypeOnly) {
keywordFilters = isTypeAssertion()
keywordFilters = contextToken && isAssertionExpression(contextToken.parent)
? KeywordCompletionFilters.TypeAssertionKeywords
: KeywordCompletionFilters.TypeKeywords;
}
@@ -1494,10 +1494,6 @@ namespace ts.Completions {
});
}
function isTypeAssertion(): boolean {
return isAssertionExpression(contextToken.parent);
}
function isTypeOnlyCompletion(): boolean {
return insideJsDocTagTypeExpression
|| !isContextTokenValueLocation(contextToken) &&