Skip to content

Commit e50f447

Browse files
committed
Fix the as operator detection
Fixes #500
1 parent 4fa9a9a commit e50f447

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ repository:
16801680
- begin: (?<!\.|\$)\b(as)\s+
16811681
beginCaptures:
16821682
'1': { name: keyword.control.as.ts }
1683-
end: (?=$|^|[;,:})\]])
1683+
end: (?=$|^|[;,:})\]]|((?<!\.|\$)\b(as)\s+))
16841684
patterns:
16851685
- include: '#type'
16861686
- name: keyword.operator.spread.ts

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4617,7 +4617,7 @@
46174617
</dict>
46184618
</dict>
46194619
<key>end</key>
4620-
<string>(?=$|^|[;,:})\]])</string>
4620+
<string>(?=$|^|[;,:})\]]|((?&lt;!\.|\$)\b(as)\s+))</string>
46214621
<key>patterns</key>
46224622
<array>
46234623
<dict>

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4563,7 +4563,7 @@
45634563
</dict>
45644564
</dict>
45654565
<key>end</key>
4566-
<string>(?=$|^|[;,:})\]])</string>
4566+
<string>(?=$|^|[;,:})\]]|((?&lt;!\.|\$)\b(as)\s+))</string>
45674567
<key>patterns</key>
45684568
<array>
45694569
<dict>

tests/baselines/Issue500.baseline.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
original file
2+
-----------------------------------
3+
0 as any as string;
4+
-----------------------------------
5+
6+
Grammar: TypeScript.tmLanguage
7+
-----------------------------------
8+
>0 as any as string;
9+
^
10+
source.ts constant.numeric.decimal.ts
11+
^
12+
source.ts
13+
^^
14+
source.ts keyword.control.as.ts
15+
^
16+
source.ts
17+
^^^
18+
source.ts support.type.primitive.ts
19+
^
20+
source.ts
21+
^^
22+
source.ts keyword.control.as.ts
23+
^
24+
source.ts
25+
^^^^^^
26+
source.ts support.type.primitive.ts
27+
^
28+
source.ts punctuation.terminator.statement.ts

tests/cases/Issue500.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 as any as string;

0 commit comments

Comments
 (0)