rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

WIP: Emit array spreads using the native es array spread syntax

Open zth opened this issue 1 year ago • 0 comments

Builds on @cometkim work in https://github.com/rescript-lang/rescript-compiler/pull/7030 to also have array spreads be emitted as actual ES array spreads.

Example:

let x = [1, 2, 3]
let y = [...x, 4, 5, 6]

Outputs:

let x = [
  1,
  2,
  3
];

let y = [
  ...x,
  4,
  5,
  6
];

2 issues that needs to be fixed currently:

  • [ ] Can't use pipes for some reason when spreading an expression. Probably need to special case the first pipe for it to work. Will add a failing test.
  • [ ] Comments seem broken, they get output in the wrong location as it's reformatted. Probably missing something obvious.
  • ~~Something changed in the list concat syntax output. Need to investigate.~~ Actually I just misread this, the change looks fine.

zth avatar Sep 12 '24 07:09 zth