FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

check the target of a type reference in isWeakType by maschwenk · Pull Request #64654 · microsoft/TypeScript · GitHub

Repository navigation

check the target of a type reference in isWeakType - #64654

Open
Max Schwenk (maschwenk) wants to merge 2 commits into
microsoft:mainfrom
maschwenk:weak-type-target
Open

Max Schwenk (maschwenk) wants to merge 2 commits into
microsoft:mainfrom
maschwenk:weak-type-target

Conversation

Max Schwenk (maschwenk) commented Oct 6, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

isWeakType resolves the members of the type it's given. for an instantiation of a generic class or interface that instantiates every declared member and copies in every inherited one, only to check that there are no signatures or index infos and every property is optional. instantiating doesn't change any of that unless a base type is a type parameter (a class declared in a generic function can extend base<T>()), so when none is, this asks the target instead, whose members are resolved once and never instantiated. weakTypeWithTypeParameterBase.ts covers the type parameter case

isRelatedToEx calls isWeakType on the target before it gets to structuredTypeRelatedTo, where two references to the same generic type are compared by variance without looking at members. so an instantiation that's only ever a relation target, and only ever related through its type arguments, still had its whole member table built here

tuple targets are left out. doing the same for them made vscode slightly worse, and tuples are never weak anyway (length is required)

heap after check (Memory used from --extendedDiagnostics), median of 3, same diagnostics with and without this:

4 checkers --singleThreaded
t3code apps/server 4.78 → 3.86 GB (−19%) 2.58 → 2.33 GB (−10%)
webpack 0.93 → 0.87 GB (−6%) 0.71 → 0.67 GB (−5%)
xstate-main 0.58 → 0.56 GB (−3%) 0.46 → 0.45 GB (−1%)
vscode 6.09 → 6.04 GB (−0.8%) 5.18 → 5.15 GB (−0.6%)
mui-docs, Compiler, Compiler-Unions within ±0.3% within ±0.3%
a private 38k-file monorepo project 19.83 → 17.55 GB (−11.5%) 13.07 → 11.85 GB (−9.3%)

on t3code peak rss goes from 5.49 to 4.62 GB with 4 checkers and the symbol count from 11.1M to 7.5M. on the monorepo project peak rss goes from 23.1 to 21.0 GB. check time doesn't get worse anywhere (it's within noise except the monorepo project single threaded, 42.9 → 38.7s)

my guess at why t3code gains the most: effect's api is built from generic interfaces with a lot of members, often through long extends chains (Rpc, the schema Bottom* interfaces, Effect), and every rpc or schema definition is its own instantiation. most checks between them are reference to reference with the same target, which variance answers from the type arguments, so before this the member tables were mostly built just for isWeakType. on t3code's server, 1.02M of the 1.03M instantiated members of Rpc came from this check

t3code is pingdotgg/t3code at 9bd1d800 (effect 4), tsc -p apps/server --noEmit. webpack, xstate-main, vscode, mui-docs and the Compiler cases are the typescript-benchmarking projects

related, avoids these resolutions (and more) by building member tables lazily:

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 6, 2026
Max Schwenk (maschwenk) marked this pull request as ready for review October 6, 2026 13:41
Copilot AI balanced review requested due to automatic review settings October 6, 2026 13:41

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copilot review overview

🟡 Changes recommended

Captured generic base types can change inherited signatures, causing incorrect weak-type diagnostics.

Review effort: Balanced
Findings: 1

Open (1) What changed in this PR

Optimizes weak-type detection to avoid resolving members for generic class/interface instantiations.

Changes:

  • Checks the generic target instead of instantiated members.
  • Excludes tuples from the optimization.
File Description
tsc/​internal/​checker/​relater.go Optimizes isWeakType for type references.

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

Comment thread tsc/internal/checker/relater.go Outdated
…eter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

typescript-automation Bot commented Oct 6, 2026 •
edited
Loading

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

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), it looks like the DT test run failed. Please check the log for more details.

You can check the log here.

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
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,276 114,129 -1,147 (- 1.00%) ~ ~ p=0.000 n=12
Types 79,613 79,277 -336 (- 0.42%) ~ ~ p=0.000 n=12
Memory Used 141,849k (± 0.33%) 141,284k (± 0.30%) ~ 140,204k 142,336k p=0.052 n=12
Memory Allocs 2,193,620 (± 0.01%) 2,191,308 (± 0.01%) -2,312 (- 0.11%) 2,190,868 2,191,763 p=0.000 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.050s (± 3.12%) 0.052s (± 4.15%) ~ 0.046s 0.056s p=0.134 n=12
Bind Time 0.015s (±13.12%) 0.015s (± 8.11%) ~ 0.013s 0.018s p=0.893 n=12
Check Time 0.592s (± 0.65%) 0.609s (± 0.86%) +0.017s (+ 2.81%) 0.599s 0.624s p=0.000 n=12
Emit Time 0.324s (± 2.30%) 0.331s (± 2.30%) ~ 0.304s 0.346s p=0.117 n=12
Total Time 0.990s (± 0.77%) 1.014s (± 1.06%) +0.025s (+ 2.52%) 0.981s 1.046s p=0.001 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 846,902 (± 0.08%) 837,259 (± 0.08%) -9,642 (- 1.14%) 836,007 838,813 p=0.000 n=12
Types 249,941 (± 0.00%) 249,860 (± 0.00%) -81 (- 0.03%) 249,856 249,868 p=0.000 n=12
Memory Used 789,309k (± 0.04%) 786,897k (± 0.03%) -2,412k (- 0.31%) 786,290k 787,654k p=0.000 n=12
Memory Allocs 12,864,708 (± 0.04%) 12,858,412 (± 0.01%) -6,295 (- 0.05%) 12,854,892 12,865,521 p=0.008 n=12
Config Time 0.020s 0.020s (± 1.21%) ~ 0.020s 0.021s p=0.478 n=12
Parse Time 0.320s (± 2.77%) 0.326s (± 2.80%) ~ 0.297s 0.346s p=0.131 n=12
Bind Time 0.084s (±18.20%) 0.077s (± 7.34%) ~ 0.069s 0.100s p=0.286 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.917s (± 1.06%) 1.928s (± 1.21%) ~ 1.897s 2.030s p=0.271 n=12
Total Time 2.355s (± 1.26%) 2.368s (± 1.15%) ~ 2.324s 2.488s p=0.139 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 4,351,480 4,356,767 +5,287 (+ 0.12%) ~ ~ p=0.000 n=12
Types 1,380,970 1,379,976 -994 (- 0.07%) ~ ~ p=0.000 n=12
Memory Used 2,974,898k (± 0.05%) 2,982,342k (± 0.04%) +7,444k (+ 0.25%) 2,979,300k 2,987,455k p=0.000 n=12
Memory Allocs 32,827,685 (± 0.06%) 32,822,610 (± 0.04%) ~ 32,781,895 32,862,134 p=0.799 n=12
Config Time 0.020s (± 1.21%) 0.020s ~ ~ ~ p=0.478 n=12
Parse Time 0.611s (± 2.56%) 0.610s (± 2.69%) ~ 0.556s 0.667s p=0.766 n=12
Bind Time 0.003s (±12.54%) 0.003s (±13.14%) ~ 0.002s 0.003s p=1.000 n=12
Check Time 10.164s (± 0.66%) 10.239s (± 0.87%) ~ 9.918s 10.400s p=0.060 n=12
Emit Time 0.525s (± 6.39%) 0.517s (± 5.00%) -0.008s (- 1.54%) 0.499s 0.647s p=0.023 n=12
Total Time 12.269s (± 0.44%) 12.327s (± 0.47%) ~ 12.218s 12.475s p=0.089 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,390,229 1,388,249 -1,980 (- 0.14%) ~ ~ p=0.000 n=12
Types 441,498 440,506 -992 (- 0.22%) ~ ~ p=0.000 n=12
Memory Used 1,681,724k (± 1.10%) 1,671,732k (± 0.76%) ~ 1,645,572k 1,718,296k p=0.671 n=12
Memory Allocs 92,114,503 (± 0.19%) 92,011,194 (± 0.12%) ~ 91,667,286 92,264,795 p=0.291 n=12
Config Time 0.004s (±11.30%) 0.004s (±12.60%) ~ 0.003s 0.005s p=0.800 n=12
Parse Time 0.244s (± 4.85%) 0.229s (± 3.00%) 🟩-0.015s (- 6.04%) 0.213s 0.249s p=0.037 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 2.167s (± 0.58%) 2.206s (± 0.76%) +0.038s (+ 1.78%) 2.155s 2.243s p=0.001 n=12
Emit Time 0.351s (± 5.10%) 0.352s (± 4.35%) ~ 0.324s 0.392s p=0.943 n=12
Total Time 28.350s (± 0.67%) 28.595s (± 0.61%) ~ 28.132s 29.024s p=0.052 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 334,953 332,790 -2,163 (- 0.65%) ~ ~ p=0.000 n=12
Types 197,616 197,112 -504 (- 0.26%) ~ ~ p=0.000 n=12
Memory Used 313,275k (± 0.04%) 312,414k (± 0.03%) -861k (- 0.27%) 312,227k 312,710k p=0.000 n=12
Memory Allocs 4,622,964 (± 0.01%) 4,619,290 (± 0.01%) -3,675 (- 0.08%) 4,617,640 4,620,791 p=0.000 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.111s (± 5.99%) 0.114s (± 4.42%) ~ 0.103s 0.127s p=0.385 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.048s (± 0.60%) 1.062s (± 0.52%) +0.014s (+ 1.32%) 1.050s 1.080s p=0.004 n=12
Emit Time 0.119s (±13.13%) 0.134s (±12.11%) ~ 0.098s 0.160s p=0.075 n=12
Total Time 1.336s (± 0.95%) 1.362s (± 0.99%) +0.026s (+ 1.95%) 1.331s 1.398s p=0.015 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 303,834 301,677 -2,157 (- 0.71%) ~ ~ p=0.000 n=12
Types 181,663 181,129 -534 (- 0.29%) ~ ~ p=0.000 n=12
Memory Used 273,883k (± 0.02%) 273,172k (± 0.02%) -712k (- 0.26%) 272,966k 273,327k p=0.000 n=12
Memory Allocs 1,615,976 (± 0.01%) 1,612,516 (± 0.01%) -3,460 (- 0.21%) 1,612,077 1,613,329 p=0.000 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.096s (± 2.91%) 0.101s (± 5.62%) ~ 0.087s 0.111s p=0.139 n=12
Bind Time 0.038s (±10.20%) 0.041s (±10.75%) ~ 0.029s 0.051s p=0.223 n=12
Check Time 0.823s (± 0.45%) 0.832s (± 0.58%) +0.010s (+ 1.16%) 0.822s 0.845s p=0.004 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.971s (± 0.41%) 0.990s (± 0.67%) +0.019s (+ 2.01%) 0.974s 1.009s p=0.000 n=12
vscode - native
Errors 380 380 ~ ~ ~ p=1.000 n=12
Symbols 10,815,602 10,650,969 -164,633 (- 1.52%) ~ ~ p=0.000 n=12
Types 3,599,368 3,587,540 -11,828 (- 0.33%) ~ ~ p=0.000 n=12
Memory Used 6,988,889k (± 0.02%) 6,936,545k (± 0.02%) -52,343k (- 0.75%) 6,934,153k 6,940,196k p=0.000 n=12
Memory Allocs 53,528,400 (± 0.02%) 53,386,874 (± 0.01%) -141,527 (- 0.26%) 53,374,098 53,406,640 p=0.000 n=12
Config Time 0.074s (± 0.53%) 0.074s (± 0.49%) ~ 0.073s 0.075s p=0.870 n=12
Parse Time 1.807s (± 3.86%) 1.795s (± 4.41%) ~ 1.641s 1.960s p=0.855 n=12
Bind Time 0.583s (±18.42%) 0.600s (±20.19%) ~ 0.434s 0.894s p=0.932 n=12
Check Time 13.623s (± 1.29%) 13.494s (± 1.35%) ~ 13.154s 13.842s p=0.410 n=12
Emit Time 4.628s (±11.07%) 5.198s (±11.18%) ~ 4.130s 6.117s p=0.089 n=12
Total Time 20.797s (± 1.88%) 21.248s (± 2.05%) ~ 20.392s 21.985s p=0.052 n=12
webpack - native
Errors 589 589 ~ ~ ~ p=1.000 n=12
Symbols 1,298,698 1,218,100 🟩-80,598 (- 6.21%) ~ ~ p=0.000 n=12
Types 614,057 604,703 -9,354 (- 1.52%) ~ ~ p=0.000 n=12
Memory Used 1,003,869k (± 0.02%) 976,904k (± 0.02%) -26,965k (- 2.69%) 976,309k 977,470k p=0.000 n=12
Memory Allocs 6,537,134 (± 0.03%) 6,461,263 (± 0.04%) -75,871 (- 1.16%) 6,455,801 6,468,841 p=0.000 n=12
Config Time 0.009s 0.009s ~ ~ ~ p=1.000 n=12
Parse Time 0.283s (± 3.97%) 0.287s (± 3.62%) ~ 0.257s 0.313s p=0.451 n=12
Bind Time 0.083s (±17.84%) 0.082s (±16.81%) ~ 0.062s 0.127s p=0.831 n=12
Check Time 2.061s (± 1.02%) 2.054s (± 1.38%) ~ 2.008s 2.162s p=0.355 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.472s (± 0.82%) 2.467s (± 1.43%) ~ 2.407s 2.588s p=0.434 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,055,167 987,563 🟩-67,604 (- 6.41%) ~ ~ p=0.000 n=12
Types 387,939 385,710 -2,229 (- 0.57%) ~ ~ p=0.000 n=12
Memory Used 610,243k (± 0.03%) 591,449k (± 0.03%) 🟩-18,793k (- 3.08%) 591,150k 592,082k p=0.000 n=12
Memory Allocs 4,880,457 (± 0.07%) 4,833,642 (± 0.08%) -46,814 (- 0.96%) 4,824,907 4,845,610 p=0.000 n=12
Config Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Parse Time 0.116s (± 2.59%) 0.115s (± 3.41%) ~ 0.105s 0.124s p=0.560 n=12
Bind Time 0.031s (±12.91%) 0.034s (±19.93%) ~ 0.025s 0.055s p=0.674 n=12
Check Time 1.062s (± 0.54%) 1.050s (± 0.73%) -0.012s (- 1.16%) 1.038s 1.081s p=0.005 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.220s (± 0.66%) 1.207s (± 0.69%) ~ 1.184s 1.233s p=0.066 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

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing baseline and pr:

Everything looks good!

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing baseline and pr:

Everything looks good!

This branch has not been deployed

No deployments
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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL