Skip to content

Commit 0225425

Browse files
authored
fix(47043): as const cast wrong colour when using typescript 4.5.2 (#47066)
1 parent 48228b8 commit 0225425

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/services/classifier.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ namespace ts {
10751075
}
10761076
return;
10771077
}
1078+
1079+
if (isConstTypeReference(token.parent)) {
1080+
return ClassificationType.keyword;
1081+
}
10781082
}
10791083
return ClassificationType.identifier;
10801084
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////1 as const;
4+
5+
const c1 = classification("original");
6+
verify.syntacticClassificationsAre(
7+
c1.numericLiteral("1"),
8+
c1.keyword("as"),
9+
c1.keyword("const"),
10+
c1.punctuation(";")
11+
);
12+
13+
14+
const c2 = classification("2020");
15+
verify.syntacticClassificationsAre(
16+
c2.semanticToken("number", "1"),
17+
c2.semanticToken("keyword", "as"),
18+
c2.semanticToken("keyword", "const"),
19+
c2.semanticToken("punctuation", ";")
20+
);

0 commit comments

Comments
 (0)