mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
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:
parent
0f9d4c78d4
commit
df5981319f
@ -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) &&
|
||||
|
||||
15
tests/cases/fourslash/completionJSDocNamePath.ts
Normal file
15
tests/cases/fourslash/completionJSDocNamePath.ts
Normal 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"] });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user