Skip to content

Commit d1a9c20

Browse files
committed
Fix the varible expression with type-annotation only that ends without semicolon
Fixes #971
1 parent c3000cb commit d1a9c20

File tree

5 files changed

+508
-42
lines changed

5 files changed

+508
-42
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ variables:
3636
propertyName: ({{anyNumber}}|({{identifier}})|{{nonIdentifierPropertyName}})
3737
propertyNameWithPrivate: ({{anyNumber}}|({{propertyIdentifier}})|{{nonIdentifierPropertyName}})
3838
constantVar: ({{constantIdentifier}})(?![_$[:alnum:]])
39-
constructsAndModifiers: '(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b'
39+
constructsAndModifiers: '(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b'
4040
endOfStatement: ';|^\s*$|(?:^\s*{{constructsAndModifiers}})'
4141
varExprStart: '{{startOfDeclaration}}\b(var|let){{endOfIdentifier}}'
4242
constExprStart: '{{startOfDeclaration}}\b(const(?!\s+enum\b)){{endOfIdentifier}}'
@@ -331,23 +331,23 @@ repository:
331331
beginCaptures:
332332
'1': { name: meta.definition.variable.ts entity.name.function.ts }
333333
'2': { name: keyword.operator.definiteassignment.ts }
334-
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))
334+
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))|({{endOfStatement}})
335335
patterns:
336336
- include: '#var-single-variable-type-annotation'
337337
- name: meta.var-single-variable.expr.ts
338338
begin: '{{constantVar}}(\!)?'
339339
beginCaptures:
340340
'1': { name: meta.definition.variable.ts variable.other.constant.ts }
341341
'2': { name: keyword.operator.definiteassignment.ts }
342-
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))
342+
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))|({{endOfStatement}})
343343
patterns:
344344
- include: '#var-single-variable-type-annotation'
345345
- name: meta.var-single-variable.expr.ts
346346
begin: ({{identifier}})(\!)?
347347
beginCaptures:
348348
'1': { name: meta.definition.variable.ts variable.other.readwrite.ts }
349349
'2': { name: keyword.operator.definiteassignment.ts }
350-
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))
350+
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))|({{endOfStatement}})
351351
patterns:
352352
- include: '#var-single-variable-type-annotation'
353353

@@ -358,14 +358,14 @@ repository:
358358
(?x)({{identifier}})(?={{functionLikeAssignmentOrType}})
359359
beginCaptures:
360360
'1': { name: meta.definition.variable.ts variable.other.constant.ts entity.name.function.ts }
361-
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))
361+
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))|({{endOfStatement}})
362362
patterns:
363363
- include: '#var-single-variable-type-annotation'
364364
- name: meta.var-single-variable.expr.ts
365365
begin: ({{identifier}})
366366
beginCaptures:
367367
'1': { name: meta.definition.variable.ts variable.other.constant.ts }
368-
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))
368+
end: (?=$|^|[;,=}]|({{startOfIdentifier}}(of|in)\s+))|({{endOfStatement}})
369369
patterns:
370370
- include: '#var-single-variable-type-annotation'
371371

TypeScript.tmLanguage

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
</dict>
196196
</dict>
197197
<key>end</key>
198-
<string>(?=[;}]|$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
198+
<string>(?=[;}]|$|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
199199
<key>patterns</key>
200200
<array>
201201
<dict>
@@ -429,7 +429,7 @@
429429
<key>begin</key>
430430
<string>(?=(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))</string>
431431
<key>end</key>
432-
<string>(?!(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?&lt;!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$)))</string>
432+
<string>(?!(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))|((?&lt;!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$)))</string>
433433
<key>patterns</key>
434434
<array>
435435
<dict>
@@ -539,7 +539,7 @@
539539
</dict>
540540
</dict>
541541
<key>end</key>
542-
<string>(?!(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?&lt;!^const|[^\._$[:alnum:]]const)(?=\s*$)))</string>
542+
<string>(?!(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))|((?&lt;!^const|[^\._$[:alnum:]]const)(?=\s*$)))</string>
543543
<key>patterns</key>
544544
<array>
545545
<dict>
@@ -719,7 +719,7 @@
719719
</dict>
720720
</dict>
721721
<key>end</key>
722-
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))</string>
722+
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))|(;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
723723
<key>patterns</key>
724724
<array>
725725
<dict>
@@ -747,7 +747,7 @@
747747
</dict>
748748
</dict>
749749
<key>end</key>
750-
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))</string>
750+
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))|(;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
751751
<key>patterns</key>
752752
<array>
753753
<dict>
@@ -775,7 +775,7 @@
775775
</dict>
776776
</dict>
777777
<key>end</key>
778-
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))</string>
778+
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))|(;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
779779
<key>patterns</key>
780780
<array>
781781
<dict>
@@ -873,7 +873,7 @@
873873
</dict>
874874
</dict>
875875
<key>end</key>
876-
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))</string>
876+
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))|(;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
877877
<key>patterns</key>
878878
<array>
879879
<dict>
@@ -896,7 +896,7 @@
896896
</dict>
897897
</dict>
898898
<key>end</key>
899-
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))</string>
899+
<string>(?=$|^|[;,=}]|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(of|in)\s+))|(;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
900900
<key>patterns</key>
901901
<array>
902902
<dict>
@@ -2116,7 +2116,7 @@
21162116
</dict>
21172117
</dict>
21182118
<key>end</key>
2119-
<string>(?=;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|(?&lt;=\})</string>
2119+
<string>(?=;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))|(?&lt;=\})</string>
21202120
<key>patterns</key>
21212121
<array>
21222122
<dict>
@@ -3098,7 +3098,7 @@
30983098
<key>begin</key>
30993099
<string>(?&lt;=:)\s*</string>
31003100
<key>end</key>
3101-
<string>(?=\s|[;),}\]:\-\+]|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3101+
<string>(?=\s|[;),}\]:\-\+]|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
31023102
<key>patterns</key>
31033103
<array>
31043104
<dict>
@@ -3338,7 +3338,7 @@
33383338
</dict>
33393339
</dict>
33403340
<key>end</key>
3341-
<string>(?&lt;=\})|(?=;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3341+
<string>(?&lt;=\})|(?=;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
33423342
<key>patterns</key>
33433343
<array>
33443344
<dict>
@@ -3395,7 +3395,7 @@
33953395
</dict>
33963396
</dict>
33973397
<key>end</key>
3398-
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3398+
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
33993399
<key>patterns</key>
34003400
<array>
34013401
<dict>
@@ -3423,7 +3423,7 @@
34233423
</dict>
34243424
</dict>
34253425
<key>end</key>
3426-
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3426+
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
34273427
<key>patterns</key>
34283428
<array>
34293429
<dict>
@@ -3444,7 +3444,7 @@
34443444
</dict>
34453445
</dict>
34463446
<key>end</key>
3447-
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3447+
<string>(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
34483448
<key>patterns</key>
34493449
<array>
34503450
<dict>
@@ -3743,7 +3743,7 @@
37433743
</dict>
37443744
</dict>
37453745
<key>end</key>
3746-
<string>(?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3746+
<string>(?=$|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
37473747
<key>patterns</key>
37483748
<array>
37493749
<dict>
@@ -3760,7 +3760,7 @@
37603760
<key>name</key>
37613761
<string>meta.export.ts</string>
37623762
<key>begin</key>
3763-
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(export)(?:\s+(type))?\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))</string>
3763+
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(export)(?:\s+(type))?\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b)))</string>
37643764
<key>beginCaptures</key>
37653765
<dict>
37663766
<key>1</key>
@@ -3775,7 +3775,7 @@
37753775
</dict>
37763776
</dict>
37773777
<key>end</key>
3778-
<string>(?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
3778+
<string>(?=$|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
37793779
<key>patterns</key>
37803780
<array>
37813781
<dict>
@@ -5752,7 +5752,7 @@
57525752
</dict>
57535753
</dict>
57545754
<key>end</key>
5755-
<string>(?=[,);}\]=&gt;:&amp;|{\?]|(extends\s+)|$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
5755+
<string>(?=[,);}\]=&gt;:&amp;|{\?]|(extends\s+)|$|;|^\s*$|(?:^\s*(?:abstract|async|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|var|while)\b))</string>
57565756
<key>patterns</key>
57575757
<array>
57585758
<dict>

0 commit comments

Comments
 (0)