Skip to content

Negated Types: Remove the concept of control-flow made "fresh" negations - #65286

Draft
Wesley Wigham (weswigham) wants to merge 25 commits into
mainfrom
weswigham/negated-types-nonfresh-control-flow
Draft

Wesley Wigham (weswigham) wants to merge 25 commits into
mainfrom
weswigham/negated-types-nonfresh-control-flow

Conversation

@weswigham

Copy link
Copy Markdown
Member

This change allows full negated types to be created in control flow, not just "fresh" ones that widen away when a position isn't contextually typed by something implying a need for a negation.

This is going to break any "exact" type matching (eg, DT) on locations where these negations are introduced, but logically shouldn't be too breaky otherwise. The other potential downside is possible performance costs - by unconditionally introducing negations, we're unconditionally growing the number of elements in control-flow produced types, in all branches.

Deduplicate fresh negations against their regular counterparts during union collection and intersection insertion. Preserve the first intersection position and ordered-set membership when replacing a fresh member, while leaving standalone fresh negations eligible for widening.

Add compiler coverage for explicit exclusions, generic array narrowing, both union operand orders, and fresh-only widening.
…ntial structures, broaden negation reduction applicability
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 3, 2026
@weswigham
Wesley Wigham (weswigham) force-pushed the weswigham/negated-types-nonfresh-control-flow branch from 4e31f35 to bf68b75 Compare November 3, 2026 21:14

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

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant