Skip to content

Commit 84238ef

Browse files
committed
Fix the logical && and || operators after as expression
Fixes #762
1 parent 1dfa3c1 commit 84238ef

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

TypeScript.YAML-tmLanguage

+2-2
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ repository:
13721372
begin: '{{startOfIdentifier}}(as)\s+'
13731373
beginCaptures:
13741374
'1': { name: keyword.control.as.ts }
1375-
end: (?=$|^|[,}]|({{startOfIdentifier}}(as)\s+))
1375+
end: (?=$|^|[,}]|\|\||\&\&|({{startOfIdentifier}}(as)\s+))
13761376
patterns:
13771377
- include: '#type'
13781378
- name: meta.object.member.ts
@@ -1618,7 +1618,7 @@ repository:
16181618
- begin: '{{startOfIdentifier}}(as)\s+'
16191619
beginCaptures:
16201620
'1': { name: keyword.control.as.ts }
1621-
end: (?=$|^|[;,:})\]]|({{startOfIdentifier}}(as)\s+)|(\s+\<))
1621+
end: (?=$|^|[;,:})\]]|\|\||\&\&|({{startOfIdentifier}}(as)\s+)|(\s+\<))
16221622
patterns:
16231623
- include: '#type'
16241624
- name: keyword.operator.spread.ts

TypeScript.tmLanguage

+2-2
Original file line numberDiff line numberDiff line change
@@ -4446,7 +4446,7 @@
44464446
</dict>
44474447
</dict>
44484448
<key>end</key>
4449-
<string>(?=$|^|[,}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
4449+
<string>(?=$|^|[,}]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
44504450
<key>patterns</key>
44514451
<array>
44524452
<dict>
@@ -5278,7 +5278,7 @@
52785278
</dict>
52795279
</dict>
52805280
<key>end</key>
5281-
<string>(?=$|^|[;,:})\]]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
5281+
<string>(?=$|^|[;,:})\]]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
52825282
<key>patterns</key>
52835283
<array>
52845284
<dict>

TypeScriptReact.tmLanguage

+2-2
Original file line numberDiff line numberDiff line change
@@ -4470,7 +4470,7 @@
44704470
</dict>
44714471
</dict>
44724472
<key>end</key>
4473-
<string>(?=$|^|[,}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
4473+
<string>(?=$|^|[,}]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
44744474
<key>patterns</key>
44754475
<array>
44764476
<dict>
@@ -5224,7 +5224,7 @@
52245224
</dict>
52255225
</dict>
52265226
<key>end</key>
5227-
<string>(?=$|^|[;,:})\]]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
5227+
<string>(?=$|^|[;,:})\]]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
52285228
<key>patterns</key>
52295229
<array>
52305230
<dict>

tests/baselines/Issue762.baseline.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
original file
2+
-----------------------------------
3+
Date as any || null
4+
-----------------------------------
5+
6+
Grammar: TypeScript.tmLanguage
7+
-----------------------------------
8+
>Date as any || null
9+
^^^^
10+
source.ts support.class.builtin.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.operator.logical.ts
23+
^
24+
source.ts
25+
^^^^
26+
source.ts constant.language.null.ts

tests/cases/Issue762.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Date as any || null

0 commit comments

Comments
 (0)