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 — only build intersection props that can reduce it to never by maschwenk · Pull Request #64476 · microsoft/TypeScript

Conversation

@maschwenk

@maschwenk Max Schwenk (maschwenk) commented Sep 27, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fixes #64474 (part 2, #64475 is part 1). doesnt depend on #64475

getReducedType checks whether an intersection reduces to never by calling getPropertiesOfUnionOrIntersectionType, which creates the combined property (and the intersection of its types) for every name in the intersection and keeps all of them around. but a combined property can only reduce the intersection if one of the constituent properties has a literal type or is private

so this moves the loop in createUnionOrIntersectionProperty that collects each constituent's property of a name into collectUnionOrIntersectionPropertyParts, and both use it. getReducedType looks at what it collected and only creates the combined property when it could reduce the intersection. theres no second copy of the checking logic. the code change is about 80 lines, the rest of the diff is one test and its baselines

similar goal to #53346, but instead of stopping early it skips creating the properties that can't reduce, which is where the memory goes

this PR alone vs main (typescript-benchmarking, median of 3):

heap, 4 checkers peak rss, 4 checkers check, 4 checkers heap, single check, single
mui-docs −41.8% −38.2% −38.9% −33.7% −28.8%
Compiler-Unions −4.7% −3.0% 0.0% −5.1% −3.8%
webpack −2.5% +1.9% −3.9% −2.9% −2.7%
xstate-main −1.2% −0.9% +3.6% −0.9% +0.5%
vscode −0.4% −0.7% −2.2% −0.3% +0.8%
Compiler −1.8% −1.0% +1.4% −0.4% −1.2%

mui-docs gets the big win since its styling types build some really big intersections. the check times on the small projects are within run to run noise. raw results and scripts: https://gist.github.com/maschwenk/c83d9185c6961b6fb43d7d071ef39cf6

i also tried an even simpler check, create the property for any name more than one constituent has (d33ab85). less code, but on our 37k-file program it held 0.28 GiB more heap, so i went back

full go suite passes (also multiple checkers and -race), lint and format are clean. added intersectionNeverReductionByProperty.ts with baselines generated on unmodified main. it covers literal/boolean/template literal discriminants, optional and never props, private vs protected, instantiations of the same generic class, generic aliases and type params with union constraints

  • associated issue in Backlog: checker builds member tables and intersection props it never uses #64474, not triaged yet
  • up to date with main
  • tests pass (go test ./... in tsc, same thing hereby test runs)
  • hereby lint
  • hereby check:format
  • new tests

used claude code to help write this, ive reviewed it

Sorry, something went wrong.

Uh oh!

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

All reactions
@maschwenk @claude
Check intersections for never-reduction without creating every property
a424002
getReducedType decided whether an intersection reduces to never by creating
the combined property of every property name of every constituent
(getPropertiesOfUnionOrIntersectionType). In large intersections most of
those synthetic properties, and the intersections of their types, are
never used again.

Only a combination of distinct constituent properties where one has a
literal type (a discriminant), a private property, or a constituent
property that is itself such a combination can satisfy
isNeverReducedProperty. isNeverReducedIntersection now collects the
constituent properties of each name as createUnionOrIntersectionProperty
does, including comparing instantiations of the same property, and only
creates the combined property for those names. When the properties of the
intersection are already resolved it checks them as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 27, 2026
This was referenced Sep 27, 2026
build member tables of instantiated classes/interfaces lazily #64475
Draft
checker builds member tables and intersection props it never uses #64474
Closed
@maschwenk Max Schwenk (maschwenk) changed the title Check intersections for never-reduction without creating every property Only build intersection properties that can reduce it to never Sep 27, 2026
@maschwenk Max Schwenk (maschwenk) changed the title Only build intersection properties that can reduce it to never only build intersection props that can reduce it to never Sep 27, 2026
Max Schwenk (maschwenk) and others added 3 commits September 27, 2026 00:10
@maschwenk @claude
Only combine properties that more than one constituent has
d33ab85
Instead of collecting the constituent properties of every name the way
createUnionOrIntersectionProperty does, create the combined property for
any name that more than one constituent has. The combined property of a
name only one constituent has is that constituent's own property, which
can only reduce the intersection if it already combines the properties of
a union.

This creates more combined properties than before, but is much simpler
and saves the per-name lookups in every constituent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@maschwenk @claude
Go back to the precise never-reduction check
5974e8f
This reverts d33ab85. The simpler check was faster on the
typescript-benchmarking projects, but on a 37k-file program it created
356k more symbols and held 0.28 GiB more heap (about 1.3 GiB more peak
RSS with 4 checkers), which is the problem this change is for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@maschwenk @claude
Share property collection with createUnionOrIntersectionProperty
120bd57
isNeverReducedIntersection re-implemented how
createUnionOrIntersectionProperty collects each constituent's property of
a name. That loop is now collectUnionOrIntersectionPropertyParts, and both
use it. From what it collects, isNeverReducedIntersection checks whether
the combined property could satisfy isNeverReducedProperty (it needs a
literal-typed or a private constituent property) before creating it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Sep 28, 2026
Only check properties with multiple declarations for never-reduction #64499
Merged
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Sep 28, 2026

Copy link
Copy Markdown
Member

Max Schwenk (@maschwenk) I have a simpler implementation in #64499 with equally nice results. Thanks much for the research!

All reactions

Sorry, something went wrong.

Uh oh!

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

@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 Sep 28, 2026
@typescript-automation typescript-automation Bot assigned Anders Hejlsberg (ahejlsberg) Sep 28, 2026
@maschwenk

Max Schwenk (maschwenk) commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Anders Hejlsberg (@ahejlsberg) shall I close this out?

All reactions

Sorry, something went wrong.

Uh oh!

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

@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Sep 28, 2026

Copy link
Copy Markdown
Member

Anders Hejlsberg (@ahejlsberg) shall I close this out?

Yes, #64499 is already in main.

maschwenk reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@maschwenk Max Schwenk (maschwenk) closed this Sep 28, 2026
@jakebailey Jake Bailey (jakebailey) added the Domain: Performance Performance related label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot will automatically review once the pull request is marked ready for review

Uh oh!

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

Assignees

@ahejlsberg Anders Hejlsberg (ahejlsberg)

Labels

Domain: Performance Performance related For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

checker builds member tables and intersection props it never uses

Uh oh!

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

3 participants

@maschwenk @ahejlsberg @jakebailey
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.