@@ -67,7 +67,7 @@ variables:
6767 typeArgumentsInnerExpressionPart : ' [^<>\(]|{{matchingParenthesis}}|(?<==)\>'
6868 typeArguments : ' <\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}(({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*(?<!=)\>))*(?<!=)\>)*(?<!=)>'
6969 functionCallLookup : \s*(?:(\?\.\s*)|(\!))?({{typeArguments}}\s*)?\(
70- returnTypeOfArrow : \s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+
70+ possiblyType : \s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+
7171 typeparamertStartOfArrow : ' '
7272 arrowLookup : |-
7373 # sure shot arrow functions even if => is on new line
@@ -84,11 +84,15 @@ variables:
8484 (
8585 {{typeParameters}}? # typeparameters
8686 \(\s*({{inlineComment}}\s*)*(([_$[:alpha:]]|{{matchingBraces}}|{{matchingBrackets}}|(\.\.\.\s*[_$[:alpha:]]))([^()]|{{matchingParenthesis}})*)?\) # parameters
87- (\s*:{{returnTypeOfArrow }})? # return type
87+ (\s*:{{possiblyType }})? # return type
8888 \s*=> # arrow operator
8989 )
9090 possiblyMultilineArrowExpressionBeforeEndOfLine : ((({{typeParameters}})?\()|(<))
91- possiblyMultilineArrow : ((<\s*$)|({{typeParameters}}?[\(]\s*([\{\[]\s*)?$)) # during lookup treat <typeparameters>?( followed by line end as arrow or < followed by new line
91+ possiblyMultilineObjectBindingPattern : ' {{matchingBraces}}\s*((:\s*\{?$)|(({{possiblyType}}\s*)?=\s*))'
92+ possiblyMultilineArrayBindingPattern : ' {{matchingBrackets}}\s*((:\s*\[?$)|(({{possiblyType}}\s*)?=\s*))'
93+ possiblyMultilineArrowWParamters : ' ((([\{\[]\s*)?$)|({{possiblyMultilineObjectBindingPattern}})|({{possiblyMultilineArrayBindingPattern}}))'
94+ possiblyMultilineArrowWithoutTypeParameters : ' [\(]\s*{{possiblyMultilineArrowWParamters}}'
95+ possiblyMultilineArrow : ((<\s*$)|({{typeParameters}}?{{possiblyMultilineArrowWithoutTypeParameters}})) # during lookup treat <typeparameters>?( followed by line end as arrow or < followed by new line
9296 functionOrArrowLookup : |-
9397 \s*(
9498 ((async\s+)?(
@@ -1390,7 +1394,7 @@ repository:
13901394 ' 0 ' : { name: meta.object-literal.key.ts punctuation.separator.key-value.ts }
13911395 end : (?=,|\})
13921396 patterns :
1393- - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?(?=\s*{{typeParameters}}\(\s*([\{\[]\s*)?$ )'
1397+ - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?(?=\s*{{typeParameters}}\(\s*{{possiblyMultilineArrowWParamters}} )'
13941398 beginCaptures :
13951399 ' 1 ' : { name: storage.modifier.async.ts }
13961400 end : (?<=\))
@@ -1404,7 +1408,7 @@ repository:
14041408 ' 0 ' : { name: meta.brace.round.ts }
14051409 patterns :
14061410 - include : ' #expression-inside-possibly-arrow-parens'
1407- - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?\s*(\()(?=\s*([\{\[]\s*)?$ )'
1411+ - begin : ' {{lookBehindOfObjectMemberPossiblyMultilineArrow}}\s*(async)?\s*(\()(?=\s*{{possiblyMultilineArrowWParamters}} )'
14081412 beginCaptures :
14091413 ' 1 ' : { name: storage.modifier.async.ts }
14101414 ' 2 ' : { name: meta.brace.round.ts }
@@ -1480,7 +1484,7 @@ repository:
14801484 # but do this only from expression and as last resort
14811485 paren-expression-possibly-arrow :
14821486 patterns :
1483- - begin : ' {{lookBehindOfPossiblyMultilineArrowWithDestructuring}}\s*(async)?(?=\s*({{typeParameters}})?\(\s*[\{\[]\s*$ )'
1487+ - begin : ' {{lookBehindOfPossiblyMultilineArrowWithDestructuring}}\s*(async)?(?=\s*({{typeParameters}})?\(\s*{{possiblyMultilineArrowWParamters}} )'
14841488 beginCaptures :
14851489 ' 1 ' : { name: storage.modifier.async.ts }
14861490 end : (?<=\))
@@ -2178,7 +2182,7 @@ repository:
21782182
21792183 # This is the check if the exoression '): something =>'' can be matched as return type of arrow
21802184 possibly-arrow-return-type :
2181- begin : (?<=\)|^)\s*(:)(?={{returnTypeOfArrow }}\s*=>)
2185+ begin : (?<=\)|^)\s*(:)(?={{possiblyType }}\s*=>)
21822186 beginCaptures :
21832187 ' 1 ' : { name: meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts }
21842188 end : ' {{arrowFunctionEnd}}'
0 commit comments