Skip to content

Commit

Permalink
Fix the logical && and || operators after as expression
Browse files Browse the repository at this point in the history
Fixes #762
  • Loading branch information
sheetalkamat committed Jul 29, 2019
1 parent 1dfa3c1 commit 84238ef
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ repository:
begin: '{{startOfIdentifier}}(as)\s+'
beginCaptures:
'1': { name: keyword.control.as.ts }
end: (?=$|^|[,}]|({{startOfIdentifier}}(as)\s+))
end: (?=$|^|[,}]|\|\||\&\&|({{startOfIdentifier}}(as)\s+))
patterns:
- include: '#type'
- name: meta.object.member.ts
Expand Down Expand Up @@ -1618,7 +1618,7 @@ repository:
- begin: '{{startOfIdentifier}}(as)\s+'
beginCaptures:
'1': { name: keyword.control.as.ts }
end: (?=$|^|[;,:})\]]|({{startOfIdentifier}}(as)\s+)|(\s+\<))
end: (?=$|^|[;,:})\]]|\|\||\&\&|({{startOfIdentifier}}(as)\s+)|(\s+\<))
patterns:
- include: '#type'
- name: keyword.operator.spread.ts
Expand Down
4 changes: 2 additions & 2 deletions TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -4446,7 +4446,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|^|[,}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
<string>(?=$|^|[,}]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -5278,7 +5278,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|^|[;,:})\]]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
<string>(?=$|^|[;,:})\]]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
<key>patterns</key>
<array>
<dict>
Expand Down
4 changes: 2 additions & 2 deletions TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -4470,7 +4470,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|^|[,}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
<string>(?=$|^|[,}]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+))</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -5224,7 +5224,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|^|[;,:})\]]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
<string>(?=$|^|[;,:})\]]|\|\||\&amp;\&amp;|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(as)\s+)|(\s+\&lt;))</string>
<key>patterns</key>
<array>
<dict>
Expand Down
26 changes: 26 additions & 0 deletions tests/baselines/Issue762.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
original file
-----------------------------------
Date as any || null
-----------------------------------

Grammar: TypeScript.tmLanguage
-----------------------------------
>Date as any || null
^^^^
source.ts support.class.builtin.ts
^
source.ts
^^
source.ts keyword.control.as.ts
^
source.ts
^^^
source.ts support.type.primitive.ts
^
source.ts
^^
source.ts keyword.operator.logical.ts
^
source.ts
^^^^
source.ts constant.language.null.ts
1 change: 1 addition & 0 deletions tests/cases/Issue762.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Date as any || null

0 comments on commit 84238ef

Please sign in to comment.