Repository navigation
check the target of a type reference in isWeakType - #64654
Max Schwenk (maschwenk) wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Captured generic base types can change inherited signatures, causing incorrect weak-type diagnostics.
Review effort: Balanced
Findings: 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.
…eter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), it looks like the DT test run failed. Please check the log for more details. |
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |

isWeakTyperesolves 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 extendbase<T>()), so when none is, this asks the target instead, whose members are resolved once and never instantiated.weakTypeWithTypeParameterBase.tscovers the type parameter caseisRelatedToExcallsisWeakTypeon the target before it gets tostructuredTypeRelatedTo, 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 heretuple targets are left out. doing the same for them made vscode slightly worse, and tuples are never weak anyway (
lengthis required)heap after check (
Memory usedfrom--extendedDiagnostics), median of 3, same diagnostics with and without this:--singleThreadedapps/serveron 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
extendschains (Rpc, the schemaBottom*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 forisWeakType. on t3code's server, 1.02M of the 1.03M instantiated members ofRpccame from this checkt3code 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 projectsrelated, avoids these resolutions (and more) by building member tables lazily:
🤖 Generated with Claude Code