Civet
Civet copied to clipboard
`jsCompat` flag for single-argument arrow functions without parens
We're planning to add a "civet jsCompat" directive (or esCompat?) that enables support for single-argument arrow functions without a paren, at the cost of no longer supporting zero-argument arrow functions without parens. Like coffeeCompat, this will be useful for gradually converting an existing code base. Also, many people are probably used to this notation so it's a useful alternative to offer.
Originally posted by @edemaine in https://github.com/DanielXMoore/Civet/issues/269#issuecomment-1399515111
Daniel suggested that jsCompat might also turn on a flag to disable all implicit (parenless) function calls, which would handle other weird behavior like for a of b {}.
More things for jsCompat flag:
- More arrow stuff #667
catchwith braced block #400- Braced blocks not always making object literals #1816
Low priority for me; I just hope any weird non-JS compatible syntax is well documented. (eg mentioned on website 1-2 times, in blog posts, etc)
For anyone migrating TS code in the meantime you can use this RegEx and replacement to wrap single non-parenthesized arrow arguments:
([a-zA-Z]*[^)]) =>
($1) =>