-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
The object spread operator can't be used with union types #1488
Comments
Any progress on this? |
@dchambers Check out my lengthy comments on #5253
The |
@Jym77 shouldn't it rather be |
Yes, maybe… And I messed up with the priority of operators. |
@Jym77, really good spot that With nominal types this would be something that generics would normally be used to solve, so I also tried this, which happens to be much DRYer too:
but that just put me back to getting the same error as I started with in the beginning. This is surprising as I would normally read this as saying that Ho hum... |
@Jym77, it just occurred to me that we can see how this should really work by testing the concept with Results from trying this are as follows:
Here's the usage code I used to prove
|
Updated Code Snippet:
|
Awesome! That also gives a decent workaround, especially when there aren't too many fields that change (using |
Hmmm… Additionally, it makes the |
Looks like this fixes the issue: #7298 |
This code no longer errors on master. |
Consider the following code snippet:
Here, Both
Y
andZ
have aparam
attribute of typestring
, so the spread operations is valid, yet it fails. The defitnition off1
shows us that spread operator works for non-union types.The text was updated successfully, but these errors were encountered: