Port TypeScript#63070: Be more lenient about iteration when lib=es5 / noLib#2753
Merged
jakebailey merged 2 commits intomainfrom Feb 11, 2026
Merged
Port TypeScript#63070: Be more lenient about iteration when lib=es5 / noLib#2753jakebailey merged 2 commits intomainfrom
jakebailey merged 2 commits intomainfrom
Conversation
…s5 / noLib When lib=es5 or noLib but target is ES2015+, we previously issued errors on iterations complaining that [Symbol.iterator]() is missing, which was impossible because there's no lib defining iterable types. This change adds a check for whether the global Iterable type exists before enabling uplevel iteration, falling back to ES5-ish behavior (allowing iteration on arrays/strings) when the iterator types are missing. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Port changes for lenient iteration handling in ES5
Port TypeScript#63070: Be more lenient about iteration when lib=es5 / noLib
Feb 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports TypeScript#63070 to the Go checker, making for..of (and related iteration features) more lenient when lib=es5/noLib but target is ES2015+, by only enabling ES2015 “uplevel iteration” semantics when the global Iterable type is actually present.
Changes:
- Gate ES2015+ iterable-based iteration checking on the existence of the global
Iterabletype (getGlobalIterableType() != emptyGenericType). - Update baseline outputs to reflect the new behavior (removing previously-spurious TS2488 iterator errors and restoring ES5-ish array/string iteration behavior when libs are missing).
- Delete/adjust many
.diffbaselines as error output converges with the intended behavior.
Reviewed changes
Copilot reviewed 93 out of 93 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/checker.go | Only enables ES2015 uplevel iteration when global Iterable exists; otherwise falls back to array/string iteration behavior. |
| testdata/baselines/reference/submodule/conformance/useObjectValuesAndEntries1(target=es2015).types.diff | Baseline diff updated due to corrected iteration typing/error behavior. |
| testdata/baselines/reference/submodule/conformance/useObjectValuesAndEntries1(target=es2015).types | Baseline types updated (e.g., for..of element types no longer degrade to any). |
| testdata/baselines/reference/submodule/conformance/useObjectValuesAndEntries1(target=es2015).errors.txt.diff | Removes now-fixed spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/conformance/useObjectValuesAndEntries1(target=es2015).errors.txt | Removes now-fixed spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/conformance/types.forAwait.es2018.3.errors.txt.diff | Baseline diff updated to reflect fallback behavior when async iterable globals are missing. |
| testdata/baselines/reference/submodule/conformance/types.forAwait.es2018.3.errors.txt | Updates expected diagnostics (e.g., array/string-based errors instead of [Symbol.asyncIterator] errors under missing libs). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3(target=es2015).types.diff | Diff baseline updated due to improved/restored destructuring iteration typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3(target=es2015).types | Reference types baseline updated (rest/spread element types no longer become any). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3(target=es2015).types.diff | Diff baseline updated due to corrected iteration/destructuring typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3(target=es2015).types | Reference types baseline updated to restored specific element/rest types. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern2(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern2(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues(target=es2015).types.diff | Diff baseline updated due to corrected for..of destructuring typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues(target=es2015).types | Reference types baseline updated (restored specific types instead of any). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues(target=es2015).symbols.diff | Diff baseline updated to reflect corrected symbol attribution under restored typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).types.diff | Diff baseline updated due to corrected for..of destructuring typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).types | Reference types baseline updated (restored specific types instead of any). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).symbols.diff | Diff baseline updated to reflect corrected symbol attribution under restored typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).symbols | Reference symbols baseline updated to match restored symbol resolution output. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2(target=es2015).types.diff | Diff baseline updated due to corrected for..of destructuring/rest typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2(target=es2015).types | Reference types baseline updated (restored specific rest element types). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues(target=es2015).errors.txt.diff | Removes spurious iterator errors from diff baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern2(target=es2015).types.diff | Diff baseline updated due to corrected for..of destructuring/rest typing. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern2(target=es2015).types | Reference types baseline updated (restored specific rest element types). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern2(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern(target=es2015).errors.txt | Removes spurious iterator errors from reference baseline. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2(target=es2015).types.diff | Diff baseline updated due to corrected destructuring/rest typing in for statements. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2(target=es2015).types | Reference types baseline updated (restored specific rest element types). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPattern2(target=es2015).types.diff | Diff baseline updated due to corrected destructuring/rest typing in for statements. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPattern2(target=es2015).types | Reference types baseline updated (restored specific rest element types). |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPattern(target=es2015).types.diff | Diff baseline updated due to corrected destructuring/rest typing in for statements. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringForArrayBindingPattern(target=es2015).types | Reference types baseline updated (avoids any[] where specific union types are expected). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=esnext).types.diff | Diff baseline updated due to new lenient iteration behavior under noLib. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=esnext).types | Reference types baseline updated (string iteration yields string, not any). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=esnext).errors.txt.diff | Removes spurious iterator errors under noLib from diff baseline. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=esnext).errors.txt | Removes spurious iterator errors under noLib from reference baseline. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=es2015).types.diff | Diff baseline updated due to new lenient iteration behavior under noLib. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=es2015).types | Reference types baseline updated (string iteration yields string, not any). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=es2015).errors.txt.diff | Removes spurious iterator errors under noLib from diff baseline. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=true,target=es2015).errors.txt | Removes spurious iterator errors under noLib from reference baseline. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=esnext).types.diff | Diff baseline updated due to corrected iteration checking semantics. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=esnext).types | Reference types baseline updated (restores correct element types for iterable cases). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=esnext).errors.txt.diff | Diff baseline updated (iterator-based TS2488 errors replaced by ES5-ish TS2495 where appropriate). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=esnext).errors.txt | Reference errors baseline updated to the expected diagnostics under the new gating. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).types.diff | Diff baseline updated due to corrected iteration checking semantics. |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).types | Reference types baseline updated (restores correct element types for iterable cases). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).errors.txt.diff | Diff baseline updated (iterator-based TS2488 errors replaced by ES5-ish TS2495 where appropriate). |
| testdata/baselines/reference/submodule/compiler/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).errors.txt | Reference errors baseline updated to the expected diagnostics under the new gating. |
Member
DanielRosenwasser
approved these changes
Feb 11, 2026
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
… noLib (#2753) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When
lib=es5ornoLibbuttargetis ES2015+, the checker would error onfor..ofloops claiming[Symbol.iterator]()is missing — which is impossible since no lib defines iterable types. This ports microsoft/TypeScript#63070.The fix checks whether the global
Iterabletype actually exists before enabling uplevel iteration. When it doesn't, we fall back to ES5-ish behavior (arrays/strings are iterable, other types are not), consistent with how we already handle missingPromisefor async/await.Many existing
.diffbaseline files are deleted as previously-spurious errors are eliminated.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.