Skip to content

Commit 3f7e967

Browse files
committed
Handle type alias declaration spanning multiple lines
Fixes #166 #206 #231
1 parent 2e290b2 commit 3f7e967

14 files changed

+1021
-30
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,14 @@ repository:
234234
'1': { name: keyword.control.export.ts }
235235
'2': { name: storage.type.type.ts }
236236
'3': { name: entity.name.type.ts }
237-
end: (?=$|[,);>]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)
237+
end: (?=[};]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)
238238
patterns:
239239
- include: '#comment'
240240
- include: '#type-parameters'
241241
- include: '#type'
242-
- name: keyword.operator.assignment.ts
243-
match: '=\s*'
242+
- match: '(=)\s*'
243+
captures:
244+
'1': { name: keyword.operator.assignment.ts }
244245

245246
enum-declaration:
246247
name: meta.enum.declaration.ts

TypeScript.tmLanguage

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,7 @@
37463746
</dict>
37473747
</dict>
37483748
<key>end</key>
3749-
<string>(?=$|[,);&gt;]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)</string>
3749+
<string>(?=[};]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)</string>
37503750
<key>name</key>
37513751
<string>meta.type.declaration.ts</string>
37523752
<key>patterns</key>
@@ -3764,10 +3764,16 @@
37643764
<string>#type</string>
37653765
</dict>
37663766
<dict>
3767+
<key>captures</key>
3768+
<dict>
3769+
<key>1</key>
3770+
<dict>
3771+
<key>name</key>
3772+
<string>keyword.operator.assignment.ts</string>
3773+
</dict>
3774+
</dict>
37673775
<key>match</key>
3768-
<string>=\s*</string>
3769-
<key>name</key>
3770-
<string>keyword.operator.assignment.ts</string>
3776+
<string>(=)\s*</string>
37713777
</dict>
37723778
</array>
37733779
</dict>

TypeScriptReact.YAML-tmLanguage

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,14 @@ repository:
238238
'1': { name: keyword.control.export.tsx }
239239
'2': { name: storage.type.type.tsx }
240240
'3': { name: entity.name.type.tsx }
241-
end: (?=$|[,);>]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)
241+
end: (?=[};]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)
242242
patterns:
243243
- include: '#comment'
244244
- include: '#type-parameters'
245245
- include: '#type'
246-
- name: keyword.operator.assignment.tsx
247-
match: '=\s*'
246+
- match: '(=)\s*'
247+
captures:
248+
'1': { name: keyword.operator.assignment.tsx }
248249

249250
enum-declaration:
250251
name: meta.enum.declaration.tsx

TypeScriptReact.tmLanguage

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,7 @@
41364136
</dict>
41374137
</dict>
41384138
<key>end</key>
4139-
<string>(?=$|[,);&gt;]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)</string>
4139+
<string>(?=[};]|\bvar\b|\blet\b|\bconst\b|\btype\b|\bfunction\b|\bclass\b|\binterface\b|\bnamespace\b|\bmodule\b|\bimport\b|\benum\b|\bdeclare\b|\bexport\b|\babstract\b|\basync\b)</string>
41404140
<key>name</key>
41414141
<string>meta.type.declaration.tsx</string>
41424142
<key>patterns</key>
@@ -4154,10 +4154,16 @@
41544154
<string>#type</string>
41554155
</dict>
41564156
<dict>
4157+
<key>captures</key>
4158+
<dict>
4159+
<key>1</key>
4160+
<dict>
4161+
<key>name</key>
4162+
<string>keyword.operator.assignment.tsx</string>
4163+
</dict>
4164+
</dict>
41574165
<key>match</key>
4158-
<string>=\s*</string>
4159-
<key>name</key>
4160-
<string>keyword.operator.assignment.tsx</string>
4166+
<string>(=)\s*</string>
41614167
</dict>
41624168
</array>
41634169
</dict>

tests/baselines/Issue114.baseline.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ interface Test {
1919
source.ts meta.type.declaration.ts entity.name.type.ts
2020
^
2121
source.ts meta.type.declaration.ts
22-
^^
22+
^
2323
source.ts meta.type.declaration.ts keyword.operator.assignment.ts
24+
^
25+
source.ts meta.type.declaration.ts
2426
^
2527
source.ts meta.type.declaration.ts string.quoted.single.ts punctuation.definition.string.begin.ts
2628
^^^^
@@ -87,7 +89,7 @@ interface Test {
8789
source.ts meta.type.declaration.ts string.quoted.single.ts
8890
^
8991
source.ts meta.type.declaration.ts string.quoted.single.ts punctuation.definition.string.end.ts
90-
^
92+
^^
9193
source.ts meta.type.declaration.ts
9294
>interface Test {
9395
^^^^^^^^^

0 commit comments

Comments
 (0)