Skip to content

Commit cbac0d4

Browse files
committed
Fix arrow parameters detection
Fixes #567
1 parent 516b442 commit cbac0d4

File tree

5 files changed

+618
-134
lines changed

5 files changed

+618
-134
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ variables:
2727
lookBehindTypeof: '^typeof|{{nonPropertyLookBehind}}typeof'
2828
lookBehindCase: '^case|{{nonPropertyLookBehind}}case'
2929
matchingParenthesis: (\([^\(\)]*\))
30+
matchingBraces: (\{[^\{\}]*\})
31+
matchingBrackets: (\[[^\[\]]*\])
3032
# Identifier start | matching braces | matching parenthesis | matching square brackets
31-
typeParamersStart: ([_$[:alpha:]]|(\{[^\{\}]*\})|{{matchingParenthesis}}|(\[[^\[\]]*\]))
33+
typeParamersStart: ([_$[:alpha:]]|{{matchingBraces}}|{{matchingParenthesis}}|{{matchingBrackets}})
3234
typeParameters: (<\s*{{typeParamersStart}}([^=<>]|=[^<]|\<\s*{{typeParamersStart}}([^=<>]|=[^<])*\>)*>\s*)
3335
# Identifier start | matching braces | matching parenthesis | matching square brackets | matching strings
3436
typeArgumentsStart: ({{typeParamersStart}}|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))
@@ -40,19 +42,19 @@ variables:
4042
(
4143
[(]\s*
4244
(
43-
([)]\s*:) | # ():
44-
((\.\.\.\s*)?{{identifier}}\s*:) # [(]param: | [(]...param:
45+
([)]\s*:) | # ():
46+
((\.\.\.\s*)?{{identifier}}\s*:) # [(]param: | [(]...param:
4547
)
4648
) |
4749
(
48-
[<]\s*{{identifier}}\s+extends\s*[^=>] # < typeparam extends
50+
[<]\s*{{identifier}}\s+extends\s*[^=>] # < typeparam extends
4951
) |
5052
# arrow function possible to detect only with => on same line
5153
(
52-
{{typeParameters}}? # typeparameters
53-
\(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
54-
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
55-
\s*=> # arrow operator
54+
{{typeParameters}}? # typeparameters
55+
\(\s*(([_$[:alpha:]]|{{matchingBraces}}|{{matchingBrackets}})([^()]|{{matchingParenthesis}})*)?\) # parameters
56+
(\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
57+
\s*=> # arrow operator
5658
)
5759
functionOrArrowLookup: |-
5860
\s*(

0 commit comments

Comments
 (0)