coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

Support export destructured assignment

Open helixbass opened this issue 7 years ago • 2 comments

Choose one: is this a bug report or feature request? Feature request

@GeoffreyBooth I came across an unsupported export syntax that appears to be standard

Input Code

export {foo, bar} = item

Expected Behavior

Should transpile to export var {foo, bar} = item

Current Behavior

Doesn't compile

Possible Solution

Guessing it won't be bad to add this as a supported grammar rule

Context

Not blocking anything, just came across it while working on AST stuff

Environment

  • CoffeeScript version:
  • Node.js version:

helixbass avatar Aug 26 '18 21:08 helixbass

Good catch. I guess this can be the workaround for now:

{foo, bar} = item
export {foo, bar}

GeoffreyBooth avatar Aug 26 '18 23:08 GeoffreyBooth

Another example of this:

export [signal, setSignal] = createSignal()

should ideally compile to

export const [signal, setSignal] = createSignal()

Same workaround works, of course:

[signal, setSignal] = createSignal()
export {signal, SetSignal}

I'll probably look into fixing this, after I finally get to revising #5398.

edemaine avatar Apr 12 '22 16:04 edemaine