Open pepkin88 opened 3 years ago
You could also consider using the keyword as
, just like with exports:
export { import1 as name1, import2 as name2, …, nameN } from …;
I think with it it would be the least confusing, as to what is the new property name.
The feature from this proposal is implemented in LiveScript. You could use it as a playground and/or inspiration on how to handle the edge cases.
Note that the LiveScript implementation of this feature is a little bit different, than the proposed one. In your example
obj.{p1: new_p1, p2: {p21}, p3 = 3}
,new_p1
is the property name in the newly created object. But in the LS implementation it would bep1
.I believe this could be the reasoning behind such order in the LS implementation:
When setting multiple properties on an object, the order is consistent with object destructuring (which work similar as in JS). In the LS docs this operation is called substructuring: