Skip to content

Commit cc5499d

Browse files
committed
Modify the rest operator detection in arrow function given that there exists spread operator now
Fixes #431
1 parent 7d67d88 commit cc5499d

File tree

5 files changed

+62
-9
lines changed

5 files changed

+62
-9
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,9 +1618,8 @@ repository:
16181618
(
16191619
[(]\s*
16201620
(
1621-
([)]\s*:) | # ():
1622-
([_$[:alpha:]][_$[:alnum:]]*\s*:) | # [(]param:
1623-
(\.\.\.) # [(]...
1621+
([)]\s*:) | # ():
1622+
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
16241623
)
16251624
) |
16261625
(

TypeScript.tmLanguage

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4451,9 +4451,8 @@
44514451
(
44524452
[(]\s*
44534453
(
4454-
([)]\s*:) | # ():
4455-
([_$[:alpha:]][_$[:alnum:]]*\s*:) | # [(]param:
4456-
(\.\.\.) # [(]...
4454+
([)]\s*:) | # ():
4455+
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
44574456
)
44584457
) |
44594458
(

TypeScriptReact.tmLanguage

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,9 +4397,8 @@
43974397
(
43984398
[(]\s*
43994399
(
4400-
([)]\s*:) | # ():
4401-
([_$[:alpha:]][_$[:alnum:]]*\s*:) | # [(]param:
4402-
(\.\.\.) # [(]...
4400+
([)]\s*:) | # ():
4401+
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
44034402
)
44044403
) |
44054404
(

tests/baselines/Issue431.baseline.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
original file
2+
-----------------------------------
3+
myFunc
4+
(...argName)
5+
6+
function otherFunc() {} // <-- Not highlighted.
7+
-----------------------------------
8+
9+
Grammar: TypeScript.tmLanguage
10+
-----------------------------------
11+
>myFunc
12+
^^^^^^
13+
source.ts variable.other.readwrite.ts
14+
^^
15+
source.ts
16+
>(...argName)
17+
^
18+
source.ts meta.brace.round.ts
19+
^^^
20+
source.ts keyword.operator.spread.ts
21+
^^^^^^^
22+
source.ts variable.other.readwrite.ts
23+
^
24+
source.ts meta.brace.round.ts
25+
^^
26+
source.ts
27+
>
28+
^^
29+
source.ts
30+
>function otherFunc() {} // <-- Not highlighted.
31+
^^^^^^^^
32+
source.ts meta.function.ts storage.type.function.ts
33+
^
34+
source.ts meta.function.ts
35+
^^^^^^^^^
36+
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
37+
^
38+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
39+
^
40+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
41+
^
42+
source.ts meta.function.ts
43+
^
44+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
45+
^
46+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
47+
^
48+
source.ts
49+
^^
50+
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
51+
^^^^^^^^^^^^^^^^^^^^^
52+
source.ts comment.line.double-slash.ts

tests/cases/Issue431.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
myFunc
2+
(...argName)
3+
4+
function otherFunc() {} // <-- Not highlighted.

0 commit comments

Comments
 (0)