-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2] Enhancement: Support object spread syntax in multiline objects without braces or commas #4600
Comments
Copying #4493 (comment) That's probably related to Tbh we probably want to leave it like this, or we'll need to face down ambiguities in expressions like f k: v, rest... Which, currently, will compile to two arguments (an object literal and a splat param) but would be ambiguous if we allowed splats to exist in implicit objects. |
As an aside, commas are still optional, even with explicit braces: {
foo...
bar
baz: 'qux'
} |
I ran into this just writing the documentation. I think it’s a thing that will be very common for people to want to do. Could we find a way to allow spreads in multiline objects, while leaving function arguments unaffected (i.e. to avoid ambiguity problems)? @helixbass this looks like a rewriter issue, if you feel like taking a crack at it. |
@GeoffreyBooth, @connec, @helixbass foo =
bar...
c: 3 compiles to foo = Object.assign({}, bar, {
c: 3
});
f(Object.assign({
a: x
}, rest)) And if I'm correct, there is also this case foo =
bar
c: 3 which should compile to foo = {
bar,
c: 3
} |
I'm not sure we want this. I read it as |
Current status: # foo =
# bar
# c: 3
foo = {
bar,
c: 3
}
# foo =
# bar c: 3
foo = bar({c:3))
# foo =
# bar
# c: 3
foo = bar({c:3)) |
See also #4551 (comment) |
Closing per discussion in #4618. |
results in
For now we have to use:
It's a bit ugly and it adds an exception to the nice CS way of object notation.
The text was updated successfully, but these errors were encountered: