Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Specified diagnostic for iterating known array type without --downlevelIteration#40070

Merged
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
Feb 18, 2021
Merged

Specified diagnostic for iterating known array type without --downlevelIteration#40070
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

Copy link
Copy Markdown
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
Comment thread src/compiler/diagnosticMessages.json Outdated
@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
Comment thread src/compiler/checker.ts

@sandersn sandersn left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/compiler/checker.ts Outdated
Comment thread src/compiler/checker.ts Outdated

@sandersn sandersn left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@sandersn were you still going to merge this?

@sandersn

Copy link
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.