Specified diagnostic for iterating known array type without --downlevelIteration#40070
Merged
sandersn merged 6 commits intoFeb 18, 2021
microsoft:mastermicrosoft/TypeScript:masterfrom
JoshuaKGoldberg:iterated-entities-no-downlevel-messageJoshuaKGoldberg/TypeScript:iterated-entities-no-downlevel-messageCopy head branch name to clipboard
Merged
Specified diagnostic for iterating known array type without --downlevelIteration#40070sandersn merged 6 commits intomicrosoft:mastermicrosoft/TypeScript:masterfrom JoshuaKGoldberg:iterated-entities-no-downlevel-messageJoshuaKGoldberg/TypeScript:iterated-entities-no-downlevel-messageCopy head branch name to clipboard
sandersn merged 6 commits into
microsoft:mastermicrosoft/TypeScript:masterfrom
JoshuaKGoldberg:iterated-entities-no-downlevel-messageJoshuaKGoldberg/TypeScript:iterated-entities-no-downlevel-messageCopy head branch name to clipboard
Conversation
JoshuaKGoldberg
commented
Aug 15, 2020
sandersn
requested changes
Sep 4, 2020
sandersn
left a comment
Member
There was a problem hiding this comment.
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.
sandersn
approved these changes
Oct 27, 2020
sandersn
left a comment
Member
There was a problem hiding this comment.
I'll merge this for 4.2 after 4.1 RC gets its own branch.
Member
|
@sandersn were you still going to merge this? |
Member
|
Sorry, I forgot about this. I merged from master, and I'll merge the PR when tests finish running. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
yieldTypeisn't calculated unless it's needed now.