Port TypeScript PR #62661: fix [Symbol.iterator]() lost on union with never - #2737
Merged
Jake Bailey (jakebailey) merged 2 commits intoFeb 10, 2026
Merged
Conversation
… never Add getReducedType() call at the start of getIterationTypesOfIterable so non-iterable types reducible to never are properly erased from unions. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Symbol.iterator lost on union with never
Port TypeScript PR #62661: fix [Symbol.iterator]() lost on union with never
Feb 10, 2026
Jake Bailey (jakebailey)
marked this pull request as ready for review
February 10, 2026 23:12
Copilot started reviewing on behalf of
Jake Bailey (jakebailey)
February 10, 2026 23:13
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ports TypeScript PR #62661, which fixes a bug where [Symbol.iterator]() was incorrectly reported as missing on union types containing never-reducible intersections (e.g., number[] | ({ t: "a" } & { t: "b" })). The fix adds a single line to reduce types before iteration checking, ensuring that impossible intersections are eliminated from unions before checking for iterator methods.
Changes:
- Add
getReducedTypecall ingetIterationTypesOfIterableto reduce types before iteration checking - Eliminate baseline diff file for
iterableWithNeverAsUnionMembertest, indicating convergence with upstream TypeScript behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/checker/checker.go | Added t = c.getReducedType(t) at the start of getIterationTypesOfIterable to reduce never-intersections before iteration checking |
| testdata/baselines/reference/submodule/compiler/iterableWithNeverAsUnionMember(target=esnext).errors.txt.diff | Removed diff file (now empty), indicating the port now matches upstream behavior |
| testdata/baselines/reference/submodule/compiler/iterableWithNeverAsUnionMember(target=esnext).errors.txt | Updated baseline showing 3 errors instead of 6 (3 spurious errors eliminated) |
Jake Bailey (jakebailey)
enabled auto-merge
February 10, 2026 23:24
Nathan Shively-Sanders (sandersn)
approved these changes
Feb 10, 2026
Jake Bailey (jakebailey)
deleted the
copilot/fix-symbol-iterator-union-never
branch
February 10, 2026 23:50
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
… never (#2737) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Jake Bailey (jakebailey)
added a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
…r]() lost on union with never (microsoft/typescript-go#2737) 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.
Ports microsoft/TypeScript#62661.
getIterationTypesOfIterablewasn't callinggetReducedType, so non-iterable types reducible tonever(e.g.{ t: "a" } & { t: "b" }) weren't being erased from unions before iteration checking. This caused[Symbol.iterator]()to be "lost":t = c.getReducedType(t)at the top ofgetIterationTypesOfIterableininternal/checker/checker.goiterableWithNeverAsUnionMemberdeleted — output now matches upstream✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.