-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer from type arguments of the same alias in inferFromObjectTypes
#57895
base: main
Are you sure you want to change the base?
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
src/compiler/checker.ts
Outdated
@@ -26187,6 +26187,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
} | |||
|
|||
function inferFromObjectTypes(source: Type, target: Type) { | |||
if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is literally copied-over from inferFromTypes
@typescript-bot test top200 @typescript-bot perf test this faster |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@jakebailey Here are the results of running the user tests comparing Everything looks good! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top 400 repos comparing Something interesting changed - please have a look. Details
|
@jakebailey could you rerun this on more top repos? I'd love to analyze this failure and I hope that running it on more repos might reveal some test cases that won't use recursive mapped types (it should be easier to analyze such ;p) |
@typescript-bot test top800 |
@jakebailey Here are the results of running the top 800 repos comparing Something interesting changed - please have a look. Details
|
I noticed that
inferFromObjectTypes
already does this "shortcircuit" between type references but it doesn't do the same in this other case. Both are handled byinferFromTypes
. The logic related to type references ininferFromObjectTypes
is almost the same as the one ininferFromTypes
(the latter has one extra condition) - including exactly the same inline comment. Something tells me that, at some point, it was copy-pasted from the other place.I verified that this added branch is sometimes hit by the existing test suite (not a lot though). I wonder if the perf tests would show anything particularly interesting here (I kinda doubt it though - based on the mentioned infrequest hits here).