-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Rest/spread placeholder #1
Comments
Closed by 8a47350. |
Hey @citycide, great work on this library. I'm curious with this pattern how to intentionally spread the first argument. A good use case would be partially applying React components: const Header = ({ title, subtitle}) => (
<>
<h1>{title}</h1>
<h2></h2>
<>
)
const CheckoutHeader = Header({ title: 'Checkout', ..._}) |
@rajington hey 👋 , thanks This would very likely require a new symbol specifically for this "asymmetric" rest/spread parameter. I've got a high bar for introducing additional symbols — I was reluctant to add One of my main goals is also to maintain a balance of sugar and clarity. And right now that balance is arguably as good it gets by doing these: const CheckoutHeader = props => Header({ title: 'Checkout', ...props })
const CheckoutHeader = Header({ title: 'Checkout', subtitle: _ }) As always you're welcome to make a strong case in favor of it. |
Thanks for the quick reply, I feel there's some ambiguity that I misinterpreted and I could see how Could |
@rajington it would be possible — Babel adds an |
Yeah, hard to say Also maybe it's not that big of a deal to not have a way to spread the first prop, I'm worried others might combine them in the way that I had but can definitely wait for it to come up. Maybe I should move this to the TC39 proposal? Not having the bare
|
@rajington there was already some discussion on the proposal over here, which is in part why the Feel free to introduce them to the idea. I'd be much more open to implementing that if it were backed up by an upcoming proposal. |
That makes a lot of sense, thank you so much for your help. This is such an exciting area! |
prior art
the old
babel-plugin-partial-application
:TC39 proposal:
These are both roughly equivalent to:
param.macro
input:
current output:
This ends up having to be called with an array (or other spreadable object) to work, ie.
log([1, 2, 3])
. Otherwise it throws an error.proposed output:
This would be a breaking change at this point so it'd have to drop in v2.0.0 - but probably should happen.
The text was updated successfully, but these errors were encountered: