Skip to content

Only check properties with multiple declarations for never-reduction - #64499

Merged
Anders Hejlsberg (ahejlsberg) merged 1 commit into
mainfrom
fix-64474
Sep 28, 2026
Merged

Anders Hejlsberg (ahejlsberg) merged 1 commit into
mainfrom
fix-64474

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Inspired by #64476, this PR optimizes getReducedType by checking only properties with declarations in multiple intersection constituents for reduction to never. The implementation is simpler than #64476 but should have the same effect.

Fixes #64474.

Copilot AI balanced review requested due to automatic review settings September 28, 2026 15:34
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 28, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 28, 2026
@ahejlsberg

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ❌ Results
perf test this faster ✅ Started 👀 Results

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new pruning behavior lacks regression coverage for reduction edge cases.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Optimizes intersection reduction by avoiding unnecessary combined-property creation.

Changes:

  • Counts property names across intersection constituents.
  • Checks only names appearing in multiple constituents for never reduction.
File Description
tsc/​internal/​checker/​checker.go Adds targeted intersection-property reduction logic.

return t
}

func (c *Checker) somePropertyReducesToNever(t *Type) bool {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are plenty of tests that already prove the existing reduction behavior.

@typescript-automation

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,332 (± 0.00%) -148 (- 0.13%) 115,327 115,337 p=0.000 n=12
Types 96,949 90,333 (± 1.67%) 🟩-6,616 (- 6.82%) 85,923 93,354 p=0.000 n=12
Memory Used 148,590k (± 0.42%) 145,270k (± 0.54%) -3,320k (- 2.23%) 144,002k 147,132k p=0.000 n=12
Memory Allocs 2,271,613 (± 0.01%) 2,233,426 (± 0.30%) -38,187 (- 1.68%) 2,215,958 2,249,382 p=0.000 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.041s (± 3.62%) 0.040s (± 3.41%) ~ 0.036s 0.043s p=0.866 n=12
Bind Time 0.013s (±13.21%) 0.012s (± 9.93%) ~ 0.010s 0.016s p=0.483 n=12
Check Time 0.497s (± 0.67%) 0.498s (± 0.93%) ~ 0.488s 0.514s p=0.559 n=12
Emit Time 0.269s (± 2.04%) 0.268s (± 1.93%) ~ 0.252s 0.282s p=0.681 n=12
Total Time 0.827s (± 0.93%) 0.825s (± 0.65%) ~ 0.814s 0.840s p=0.619 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 847,449 (± 0.08%) 846,851 (± 0.07%) ~ 845,103 847,992 p=0.101 n=12
Types 250,003 (± 0.00%) 249,974 (± 0.01%) -29 (- 0.01%) 249,938 250,012 p=0.003 n=12
Memory Used 793,750k (± 0.08%) 790,591k (± 0.07%) -3,159k (- 0.40%) 789,112k 792,107k p=0.000 n=12
Memory Allocs 12,970,052 (± 0.12%) 12,937,786 (± 0.07%) -32,266 (- 0.25%) 12,931,035 12,980,389 p=0.000 n=12
Config Time 0.016s 0.016s ~ ~ ~ p=1.000 n=12
Parse Time 0.271s (± 2.63%) 0.273s (± 2.23%) ~ 0.255s 0.285s p=0.723 n=12
Bind Time 0.068s (±14.69%) 0.065s (±16.57%) ~ 0.057s 0.117s p=0.210 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.633s (± 1.64%) 1.614s (± 1.33%) ~ 1.584s 1.671s p=0.259 n=12
Total Time 2.008s (± 1.87%) 1.986s (± 1.47%) ~ 1.939s 2.077s p=0.326 n=12
mui-docs - native
Errors 11,399 (± 0.03%) 11,400 (± 0.04%) ~ 11,382 11,405 p=0.364 n=12
Symbols 4,303,968 4,092,318 (± 0.02%) 🟩-211,651 (- 4.92%) 4,090,308 4,094,053 p=0.000 n=12
Types 1,511,034 1,502,553 (± 0.00%) -8,481 (- 0.56%) 1,502,488 1,502,588 p=0.000 n=12
Memory Used 4,766,018k (± 0.03%) 2,953,064k (± 0.05%) 🟩-1,812,954k (-38.04%) 2,948,725k 2,955,670k p=0.000 n=12
Memory Allocs 42,541,906 (± 0.04%) 37,281,228 (± 0.07%) 🟩-5,260,678 (-12.37%) 37,217,276 37,349,519 p=0.000 n=12
Config Time 0.016s (± 1.98%) 0.015s (± 2.10%) ~ 0.015s 0.016s p=0.414 n=12
Parse Time 0.583s (± 1.69%) 0.582s (± 1.52%) ~ 0.548s 0.598s p=0.580 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 14.830s (± 0.54%) 8.733s (± 0.53%) 🟩-6.097s (-41.11%) 8.619s 8.890s p=0.000 n=12
Emit Time 0.464s (± 2.32%) 0.468s (± 9.57%) ~ 0.425s 0.677s p=0.504 n=12
Total Time 16.647s (± 0.46%) 10.579s (± 0.46%) 🟩-6.068s (-36.45%) 10.467s 10.720s p=0.000 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,252 1,391,780 (± 0.00%) -2,473 (- 0.18%) 1,391,695 1,391,852 p=0.000 n=12
Types 443,566 442,846 (± 0.01%) -721 (- 0.16%) 442,717 443,084 p=0.000 n=12
Memory Used 1,685,197k (± 0.75%) 1,675,091k (± 0.62%) ~ 1,655,442k 1,721,368k p=0.128 n=12
Memory Allocs 93,459,680 (± 0.14%) 92,666,861 (± 0.12%) -792,819 (- 0.85%) 92,462,909 92,958,778 p=0.000 n=12
Config Time 0.004s (±11.74%) 0.004s (±13.36%) ~ 0.002s 0.005s p=0.677 n=12
Parse Time 0.201s (± 3.70%) 0.204s (± 4.76%) ~ 0.184s 0.234s p=0.943 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.841s (± 0.45%) 1.814s (± 0.60%) -0.028s (- 1.51%) 1.783s 1.835s p=0.000 n=12
Emit Time 0.302s (± 3.75%) 0.294s (± 5.71%) ~ 0.263s 0.340s p=0.523 n=12
Total Time 23.791s (± 0.61%) 23.425s (± 0.59%) -0.366s (- 1.54%) 23.142s 23.820s p=0.001 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,531 335,926 (± 0.01%) -1,605 (- 0.48%) 335,863 335,965 p=0.000 n=12
Types 198,885 198,347 (± 0.03%) -538 (- 0.27%) 198,206 198,480 p=0.000 n=12
Memory Used 319,674k (± 0.02%) 314,338k (± 0.03%) -5,336k (- 1.67%) 314,117k 314,537k p=0.000 n=12
Memory Allocs 4,673,007 (± 0.01%) 4,624,240 (± 0.02%) -48,767 (- 1.04%) 4,622,144 4,626,234 p=0.000 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.117s (± 5.61%) 0.114s (± 4.80%) ~ 0.100s 0.126s p=0.503 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.064s (± 0.53%) 1.047s (± 0.36%) -0.017s (- 1.60%) 1.036s 1.059s p=0.000 n=12
Emit Time 0.122s (±12.73%) 0.135s (±11.76%) ~ 0.102s 0.164s p=0.053 n=12
Total Time 1.358s (± 1.08%) 1.348s (± 1.01%) ~ 1.313s 1.379s p=0.401 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,179 304,312 (± 0.00%) -867 (- 0.28%) 304,287 304,343 p=0.000 n=12
Types 181,926 181,813 (± 0.01%) -113 (- 0.06%) 181,789 181,837 p=0.000 n=12
Memory Used 277,162k (± 0.03%) 274,552k (± 0.02%) -2,610k (- 0.94%) 274,398k 274,669k p=0.000 n=12
Memory Allocs 1,642,366 (± 0.02%) 1,620,750 (± 0.02%) -21,616 (- 1.32%) 1,620,009 1,621,571 p=0.000 n=12
Config Time 0.000s (±146.91%) 0.000s (±146.91%) ~ 0.000s 0.001s p=1.000 n=12
Parse Time 0.101s (± 4.12%) 0.102s (± 4.42%) ~ 0.091s 0.113s p=0.764 n=12
Bind Time 0.041s (±10.79%) 0.038s (±12.48%) ~ 0.027s 0.052s p=0.433 n=12
Check Time 0.843s (± 0.44%) 0.829s (± 0.64%) -0.013s (- 1.57%) 0.816s 0.841s p=0.000 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.998s (± 0.82%) 0.983s (± 0.58%) -0.015s (- 1.49%) 0.965s 0.997s p=0.001 n=12
vscode - native
Errors 376 376 ~ ~ ~ p=1.000 n=12
Symbols 9,966,435 9,965,808 (± 0.00%) -627 (- 0.01%) 9,965,784 9,965,833 p=0.000 n=12
Types 3,360,533 3,360,469 (± 0.00%) -64 (- 0.00%) 3,360,428 3,360,493 p=0.000 n=12
Memory Used 6,541,432k (± 0.02%) 6,522,506k (± 0.01%) -18,925k (- 0.29%) 6,520,107k 6,524,394k p=0.000 n=12
Memory Allocs 50,314,406 (± 0.02%) 50,173,949 (± 0.01%) -140,457 (- 0.28%) 50,167,561 50,189,146 p=0.000 n=12
Config Time 0.067s (± 0.46%) 0.066s (± 0.49%) ~ 0.066s 0.067s p=0.414 n=12
Parse Time 1.835s (± 3.95%) 1.811s (± 3.32%) ~ 1.673s 1.948s p=0.370 n=12
Bind Time 0.524s (±20.47%) 0.479s (±22.06%) ~ 0.400s 0.848s p=0.171 n=12
Check Time 13.702s (± 1.47%) 13.805s (± 1.21%) ~ 13.247s 13.977s p=0.876 n=12
Emit Time 4.528s (±11.78%) 4.047s (±10.93%) ~ 3.638s 5.498s p=0.178 n=12
Total Time 20.766s (± 1.80%) 20.312s (± 1.73%) -0.454s (- 2.18%) 19.857s 21.451s p=0.017 n=12
webpack - native
Errors 848 848 ~ ~ ~ p=1.000 n=12
Symbols 1,376,073 1,374,324 (± 0.00%) -1,749 (- 0.13%) 1,374,265 1,374,409 p=0.000 n=12
Types 603,821 603,141 (± 0.03%) -680 (- 0.11%) 602,503 603,532 p=0.000 n=12
Memory Used 968,858k (± 0.02%) 953,554k (± 0.01%) -15,304k (- 1.58%) 953,303k 953,798k p=0.000 n=12
Memory Allocs 6,270,549 (± 0.02%) 6,157,161 (± 0.02%) -113,388 (- 1.81%) 6,154,230 6,160,036 p=0.000 n=12
Config Time 0.009s 0.009s (± 5.25%) ~ 0.009s 0.011s p=0.478 n=12
Parse Time 0.263s (± 2.55%) 0.268s (± 3.03%) ~ 0.242s 0.284s p=0.297 n=12
Bind Time 0.072s (±19.38%) 0.067s (±17.85%) ~ 0.053s 0.106s p=0.619 n=12
Check Time 2.007s (± 0.49%) 2.038s (± 2.48%) ~ 1.950s 2.223s p=0.640 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.388s (± 0.25%) 2.419s (± 2.29%) ~ 2.347s 2.613s p=0.921 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,045,695 1,045,060 (± 0.00%) -635 (- 0.06%) 1,045,059 1,045,061 p=0.000 n=12
Types 383,049 382,957 (± 0.00%) -92 (- 0.02%) 382,956 382,957 p=0.000 n=12
Memory Used 611,284k (± 0.01%) 605,191k (± 0.01%) -6,093k (- 1.00%) 605,010k 605,410k p=0.000 n=12
Memory Allocs 4,828,314 (± 0.03%) 4,792,231 (± 0.04%) -36,083 (- 0.75%) 4,787,988 4,796,294 p=0.000 n=12
Config Time 0.003s (±12.54%) 0.003s (± 8.64%) ~ 0.002s 0.003s p=0.371 n=12
Parse Time 0.145s (± 3.19%) 0.151s (± 3.20%) ~ 0.138s 0.161s p=0.080 n=12
Bind Time 0.040s (±19.98%) 0.043s (±18.49%) ~ 0.033s 0.071s p=0.302 n=12
Check Time 1.194s (± 0.40%) 1.206s (± 1.75%) ~ 1.170s 1.283s p=0.744 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.390s (± 0.61%) 1.414s (± 1.57%) +0.024s (+ 1.71%) 1.373s 1.485s p=0.037 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests with tsc comparing main and refs/pull/64499/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-automation

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), it looks like the DT test run failed. Please check the log for more details.

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/64499/merge:

Everything looks good!

@jakebailey Jake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wowza

@ahejlsberg
Anders Hejlsberg (ahejlsberg) added this pull request to the merge queue Sep 28, 2026
@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
Merged via the queue into main with commit 04228e2 Sep 28, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

checker builds member tables and intersection props it never uses

4 participants