Skip to content

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

Conversation

JoshuaKGoldberg
Copy link
Contributor

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.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Aug 15, 2020
@JoshuaKGoldberg JoshuaKGoldberg changed the title Specified diganostic for iterating known array type without --downlevelIteration Specified diagnostic for iterating known array type without --downlevelIteration Aug 15, 2020
Copy link
Member

@sandersn sandersn left a 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.

Copy link
Member

@sandersn sandersn left a 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 sandersn self-assigned this Oct 27, 2020
@DanielRosenwasser
Copy link
Member

@sandersn were you still going to merge this?

@sandersn
Copy link
Member

Sorry, I forgot about this. I merged from master, and I'll merge the PR when tests finish running.

@sandersn sandersn merged commit c3d7a56 into microsoft:master Feb 18, 2021
@JoshuaKGoldberg JoshuaKGoldberg deleted the iterated-entities-no-downlevel-message branch February 18, 2021 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Given better error messages for iterated entities when not using --downlevelIteration
4 participants