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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) &&

View File

@ -0,0 +1,15 @@
// @noLib: true
/// <reference path='fourslash.ts'/>
// fix crash from #38407
//// /**
//// * @returns {modu/*1*/le:ControlFlow}
//// */
//// export function cargo() {
//// }
goTo.marker('1');
verify.completions({ marker: "1", excludes: ["module", "ControlFlow"] });