-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(javascript/typescript): lambda with parens in parameters fails (#…
…2502) * fix(javascript/typescript): lambda with parens in parameters fails - Fixes both JavaScript and TypeScript grammars Fixes samples like: const bad = ((a, b) => [...a, b]); sides.every((length,width=(3+2+(4/5))) => length > 0 ); This is done by counting parens in the regex that finds arrows functions. Currently we can only handle 2 levels of nesting as shown in the second example above. * allow much richer highlighting inside params * improve highlighting inside arguments on typescript
- Loading branch information
1 parent
7502e42
commit 0afd0d3
Showing
8 changed files
with
102 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
<span class="hljs-keyword">var</span> f = <span class="hljs-function"><span class="hljs-params">x</span> =></span> x; | ||
f(<span class="hljs-function"><span class="hljs-params">x</span> =></span> x + <span class="hljs-function">(<span class="hljs-params">y=<span class="hljs-number">2</span>, z=<span class="hljs-literal">undefined</span>, ...rest</span>) =></span> y); | ||
<span class="hljs-function"><span class="hljs-params">()</span> =></span> <span class="hljs-literal">null</span>; | ||
<span class="hljs-function">() =></span> <span class="hljs-literal">null</span>; | ||
<span class="hljs-keyword">const</span> FC = <span class="hljs-function"><span class="hljs-params">props</span> =></span> <span class="xml"><span class="hljs-tag"><<span class="hljs-name">p</span>></span>functional component<span class="hljs-tag"></<span class="hljs-name">p</span>></span></span>; | ||
|
||
<span class="hljs-keyword">const</span> good = <span class="hljs-function">() =></span> <span class="hljs-number">0</span>; | ||
<span class="hljs-keyword">const</span> good = <span class="hljs-function">(<span class="hljs-params">x</span>) =></span> <span class="hljs-number">0</span>; | ||
<span class="hljs-keyword">const</span> bad = (<span class="hljs-function"><span class="hljs-params">a</span> =></span> [...a, b]); | ||
<span class="hljs-keyword">const</span> bad = (<span class="hljs-function"><span class="hljs-params">_</span> =></span> doSomething()); | ||
<span class="hljs-keyword">const</span> bad = (<span class="hljs-function">() =></span> <span class="hljs-number">0</span>); | ||
<span class="hljs-keyword">const</span> bad = (<span class="hljs-function">(<span class="hljs-params">a, b</span>) =></span> [...a, b]); | ||
<span class="hljs-keyword">const</span> array = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].reduce(<span class="hljs-function">(<span class="hljs-params">acc, next</span>) =></span> [...acc, next], []); | ||
sides.every(<span class="hljs-function">(<span class="hljs-params">length,width=(<span class="hljs-number">3</span>+<span class="hljs-number">2</span>+(<span class="hljs-number">4</span>/<span class="hljs-number">5</span>))</span>) =></span> length > <span class="hljs-number">0</span> ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters