Skip to content

Commit d779a19

Browse files
authored
fix(40432): show as keyword in function context (microsoft#40481)
1 parent 02f5001 commit d779a19

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/harness/fourslashInterfaceImpl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ namespace FourSlashInterface {
13701370
"let",
13711371
"package",
13721372
"yield",
1373+
"as",
13731374
"async",
13741375
"await",
13751376
].map(keywordEntry);
@@ -1510,6 +1511,7 @@ namespace FourSlashInterface {
15101511
"let",
15111512
"package",
15121513
"yield",
1514+
"as",
15131515
"async",
15141516
"await",
15151517
].map(keywordEntry);

src/services/completions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,6 @@ namespace ts.Completions {
25852585
|| kind === SyntaxKind.ModuleKeyword
25862586
|| kind === SyntaxKind.TypeKeyword
25872587
|| kind === SyntaxKind.NamespaceKeyword
2588-
|| kind === SyntaxKind.AsKeyword
25892588
|| isTypeKeyword(kind) && kind !== SyntaxKind.UndefinedKeyword;
25902589
case KeywordCompletionFilters.FunctionLikeBodyKeywords:
25912590
return isFunctionLikeBodyKeyword(kind);
@@ -2660,6 +2659,7 @@ namespace ts.Completions {
26602659
function isFunctionLikeBodyKeyword(kind: SyntaxKind) {
26612660
return kind === SyntaxKind.AsyncKeyword
26622661
|| kind === SyntaxKind.AwaitKeyword
2662+
|| kind === SyntaxKind.AsKeyword
26632663
|| !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
26642664
}
26652665

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////const x = this /*1*/
4+
////function foo() {
5+
//// const x = this /*2*/
6+
////}
7+
8+
verify.completions({
9+
marker: ["1", "2"],
10+
includes: [{ name: "as", sortText: completion.SortText.GlobalsOrKeywords }]
11+
});

0 commit comments

Comments
 (0)