Skip to content

Commit df59813

Browse files
authored
Fix crash on completion in jsdoc namepath (microsoft#39347)
contextToken may be undefined, so the isAssertionExpression call in filterGlobalCompletion needs to check for undefined.
1 parent 0f9d4c7 commit df59813

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/services/completions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ namespace ts.Completions {
14641464
function filterGlobalCompletion(symbols: Symbol[]): void {
14651465
const isTypeOnly = isTypeOnlyCompletion();
14661466
if (isTypeOnly) {
1467-
keywordFilters = isTypeAssertion()
1467+
keywordFilters = contextToken && isAssertionExpression(contextToken.parent)
14681468
? KeywordCompletionFilters.TypeAssertionKeywords
14691469
: KeywordCompletionFilters.TypeKeywords;
14701470
}
@@ -1494,10 +1494,6 @@ namespace ts.Completions {
14941494
});
14951495
}
14961496

1497-
function isTypeAssertion(): boolean {
1498-
return isAssertionExpression(contextToken.parent);
1499-
}
1500-
15011497
function isTypeOnlyCompletion(): boolean {
15021498
return insideJsDocTagTypeExpression
15031499
|| !isContextTokenValueLocation(contextToken) &&
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @noLib: true
2+
3+
/// <reference path='fourslash.ts'/>
4+
5+
// fix crash from #38407
6+
7+
//// /**
8+
//// * @returns {modu/*1*/le:ControlFlow}
9+
//// */
10+
//// export function cargo() {
11+
//// }
12+
13+
goTo.marker('1');
14+
verify.completions({ marker: "1", excludes: ["module", "ControlFlow"] });
15+

0 commit comments

Comments
 (0)