GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Preserve widening literals when narrowing primitive unions by equality by Andarist · Pull Request #64771 · microsoft/TypeScript

Conversation

@Andarist

@Andarist Mateusz Burzyński (Andarist) commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

fixes #64766

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Andarist
Preserve widening literals when narrowing primitive unions by equality
c6a5099
Copilot AI balanced review requested due to automatic review settings October 13, 2026 14:47
@github-project-automation github-project-automation Bot added this to PR Backlog Oct 13, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 13, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 13, 2026
Copilot started reviewing on behalf of Mateusz Burzyński (Andarist) October 13, 2026 14:49
View session
Copilot AI reviewed Oct 13, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The targeted fix matches the previous general-path behavior and is covered by focused regression and negative-control tests.

0 open findings

What changed in this PR

Fixes equality narrowing so primitive unions retain widening literal freshness while explicit literal unions remain non-widening.

Changes:

  • Distinguishes exact literal constituents from primitive containment.
  • Adds regression coverage for strings, numbers, bigints, mutable inference, and flatMap.
File Description
tsc/​internal/​checker/​flow.go Preserves literal freshness during equality narrowing.
tsc/​testdata/​tests/​cases/​compiler/​narrowingByEqualityPreservesWideningLiterals.ts Adds regression and control cases.
tsc/​testdata/​baselines/​reference/​compiler/​narrowingByEqualityPreservesWideningLiterals.types Records inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​narrowingByEqualityPreservesWideningLiterals.symbols Records resolved symbols.
tsc/​testdata/​baselines/​reference/​compiler/​narrowingByEqualityPreservesWideningLiterals.errors.txt Records expected control-case diagnostics.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@typescript-automation typescript-automation Bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 13, 2026
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) requested a review from Anders Hejlsberg (ahejlsberg) October 13, 2026 17:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@ahejlsberg Anders Hejlsberg (ahejlsberg) Awaiting requested review from ahejlsberg

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

PR Backlog
Status: Not started

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

=== narrowing of a primitive union now produces a non-widening literal type (regression from microsoft/typescript-go#4781)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Andarist
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.