Skip to content

Commit 420b920

Browse files
author
Andy
authored
Merge pull request #9271 from Microsoft/classify_this
Classify `this` in parameter position as a keyword
2 parents 8b5616d + c0eb472 commit 420b920

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/services/services.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7541,7 +7541,8 @@ namespace ts {
75417541
return;
75427542
case SyntaxKind.Parameter:
75437543
if ((<ParameterDeclaration>token.parent).name === token) {
7544-
return ClassificationType.parameterName;
7544+
const isThis = token.kind === SyntaxKind.Identifier && (<Identifier>token).originalKeywordKind === SyntaxKind.ThisKeyword;
7545+
return isThis ? ClassificationType.keyword : ClassificationType.parameterName;
75457546
}
75467547
return;
75477548
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////function f(this){}
4+
5+
var c = classification;
6+
verify.syntacticClassificationsAre(
7+
c.keyword("function"),
8+
c.identifier("f"),
9+
c.punctuation("("),
10+
c.keyword("this"),
11+
c.punctuation(")"),
12+
c.punctuation("{"),
13+
c.punctuation("}"));

0 commit comments

Comments
 (0)