language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

Support for ECMAScript 6 and 7

Open erikd opened this issue 6 years ago • 13 comments

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.

erikd avatar Jun 17 '18 03:06 erikd

const was already supported and let as added in PR #72.

erikd avatar Jun 17 '18 04:06 erikd

Support for the spread operator was added in #73.

erikd avatar Jun 17 '18 04:06 erikd

Arrow expressions were added in #74.

erikd avatar Jun 17 '18 06:06 erikd

@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 😄

Cmdv avatar Sep 06 '18 19:09 Cmdv

Absolutely fine.

Unfortunately, I have not done much more than merge patches for some time.

erikd avatar Sep 07 '18 08:09 erikd

I'd like to pick up where @Cmdv left off on import parsing.

hdgarrood avatar Feb 15 '19 01:02 hdgarrood

Also missing, it seems:

  • [ ] trailing commas: {x,y,}
  • [ ] unparenthesized single-argument arrow functions: x => 42
  • [ ] export for function: export function f() {} (looks like export const f = () => undefined works)

fare avatar Jun 12 '19 21:06 fare

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.

kl0tl avatar Jun 16 '19 22:06 kl0tl

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.

jeapostrophe avatar Sep 11 '19 16:09 jeapostrophe

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, and super (#108)

rhendric avatar Sep 29 '19 14:09 rhendric

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!

ronyhe avatar Mar 08 '20 08:03 ronyhe

Its a strictness annotation. See eg: https://wiki.haskell.org/Performance/Strictness

erikd avatar Mar 08 '20 08:03 erikd

Any reason to stop at ES7? I'm personally missing ?? and ?.

georgefst avatar Sep 24 '23 12:09 georgefst