-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
fix: Enable each
to Handle Unions of Arrays
#1218
Conversation
Example use case: ``` const array: string[] | SomeInterface[] = []; ```
Thanks for the PR! Could you add a test that confirms the behavior by adding a test within From a quick test in the TS playground it seems that the value of an element in the array is |
Edit: Nevermind. I think I misunderstood. 😬 |
Okay, the tests should be added now. Let me know if anything more is needed. Some notes:
|
From the new commits, it seems like the preference would be Let me know if anything else is needed on my part. Again, happy to squash manually to clean up the history when everything is done. |
All good, I squash the commits when merging. Thank you for taking a look at this and fixing it! |
For sure! Do you know when |
There's no regular schedule, it's more or less "has enough stuff accumulated and/or did enough time pass between two releases". I'll likely release tomorrow or early next week. When the referenced issue is closed, it's released. |
Fixes a overzealous check introduced through sveltejs#1218
Fixes a overzealous check introduced through #1218 When checking JS, the check would infer the type of an array entry to unknown instead of any, when the type of the array was any
Example use case:
Previously, the above code would cause a TS error within the
each
block, because the current version ofsvelte2tsx
does not support unions of arrays. This PR resolves that problem.Fixes #732.
I wasn't aware that the change was literally this simple. I would've submitted a PR earlier if I was aware. (Sorry 😬)
Notes:
yarn test
still passes with this implementation. ✅ (I confirmed thatyarn test
fails if I make__sveltets_1_each
an bad/inconsistent type.)Happy to do additional work if needed.