-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Specified diagnostic for iterating known array type without --downlevelIteration #40070
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
Specified diagnostic for iterating known array type without --downlevelIteration #40070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good save a couple of nitpicks. I think a static list of types is fine because I doubt the list will expand much over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this for 4.2 after 4.1 RC gets its own branch.
@sandersn were you still going to merge this? |
Sorry, I forgot about this. I merged from master, and I'll merge the PR when tests finish running. |
Fixes #16022
If an entity can't be iterated for lack of a
[Symbol.iterator]
and is one of a few known array-like types that would receive it in--downlevelIteration
, a more specific error message indicating so is now emitted.I think an ideal solution would have been to check whether the type would be iterable in a higher output target, but I couldn't find prior art in code for doing so. Is there a better way to check for this case, or an existing or larger list of known names?
Refactors the big multi-level ternary previously used to generate the diagnostic message because it would have been even more multi-level from this change. Teeny improvement:
yieldType
isn't calculated unless it's needed now.