language-javascript
language-javascript copied to clipboard
Support for ECMAScript 6 and 7
This implements features for es 6 & 7.
- [x] const and let
- [x] arrow expressions
- [ ] import
- [ ] export
- [ ] default arguments
- [ ] object matching (destructuring, single name bind)
- [x] spread operator
- [ ] classes + extends
- [ ] template strings
Each of these should be implemented in a separate PR and each item needs tests. There are likely to be three tests needed, one for the appropriate XParser.hs test and one in each if Minify.hs and RoundTrip.hs.
const was already supported and let as added in PR #72.
Support for the spread operator was added in #73.
Arrow expressions were added in #74.
@erikd would it be ok to work on import and export individually? I spotted the work was done in the original big PR. Just don't want to do it if you are already working on it 😄
Absolutely fine.
Unfortunately, I have not done much more than merge patches for some time.
I'd like to pick up where @Cmdv left off on import parsing.
Also missing, it seems:
- [ ] trailing commas:
{x,y,} - [ ] unparenthesized single-argument arrow functions:
x => 42 - [ ] export for function:
export function f() {}(looks likeexport const f = () => undefinedworks)
Support for unparenthesized single-argument arrow functions was added in https://github.com/erikd/language-javascript/pull/90 and export for function declarations in https://github.com/erikd/language-javascript/pull/88.
const [a, b] = f(); is not supported. It should be easy to just change the VariableDeclaration case to allow ArrayLiteral
edit: I updated to the last checkout and I think it is now supported.
I knocked off a bunch of the outstanding ES7 items in some work that's now released in 0.6.0.14:
- single name bind (#94)
- template literals (#95, #106)
- variable destructuring:
const [a, b] = f()(#96) - computed property names:
{[a + b]: c}(#99) - default arguments (#100)
- rest parameters (also #100)
- destructuring in parameters (also #100)
- generators and
yield(#105) - method syntax in object literals (#107)
class,extends,static, andsuper(#108)
Hi all, I'd like to contribute some work here, but I'm unfamiliar with the ! syntax in the AST module: https://github.com/erikd/language-javascript/blob/38e48dd49ccea05675515e8323c0e0035ff97bea/src/Language/JavaScript/Parser/AST.hs#L55
Can someone please refer me to an article/explanation?
Thanks in advance!
Its a strictness annotation. See eg: https://wiki.haskell.org/Performance/Strictness
Any reason to stop at ES7? I'm personally missing ?? and ?.