Skip to content

Commit 867470c

Browse files
authored
fix(47783): show globals completion in case keyword outside of switch statement (microsoft#47786)
1 parent afeacf4 commit 867470c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/services/completions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,8 @@ namespace ts.Completions {
16801680
case SyntaxKind.NewKeyword:
16811681
return checker.getContextualType(parent as Expression);
16821682
case SyntaxKind.CaseKeyword:
1683-
return getSwitchedType(cast(parent, isCaseClause), checker);
1683+
const caseClause = tryCast(parent, isCaseClause);
1684+
return caseClause ? getSwitchedType(caseClause, checker) : undefined;
16841685
case SyntaxKind.OpenBraceToken:
16851686
return isJsxExpression(parent) && !isJsxElement(parent.parent) && !isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
16861687
default:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////case /**/
4+
5+
verify.completions({ marker: "", exact: completion.globals });
6+

0 commit comments

Comments
 (0)