-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Infer into recursive mapped type targets #53647
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 into recursive mapped type targets #53647
Conversation
src/compiler/checker.ts
Outdated
@@ -2064,7 +2064,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
/** Key is "/path/to/a.ts|/path/to/b.ts". */ | |||
var amalgamatedDuplicates: Map<string, DuplicateInfoForFiles> | undefined; | |||
var reverseMappedCache = new Map<string, Type | undefined>(); | |||
var inInferTypeForHomomorphicMappedType = false; |
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.
the flag was "global" and thus prevented recursing here just for any type even if source
was different or if we'd encounter different target
s
src/compiler/checker.ts
Outdated
const key = source.id + "," + target.id + "," + constraint.id; | ||
if (reverseMappedCache.has(key)) { | ||
return reverseMappedCache.get(key); | ||
const recursionKey = source.id + "," + (target.target || target).id; |
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.
(target.target || target).id
bit could theoretically be grabbed from getRecursionIdentity
if only we'd add a special branch for mapped types there. I've done a preliminary experiment and it seems that the whole test suite would pass with such a change but at the same time... I know what kind of a type I have here and thus I can compute this key directly instead of going through an abstraction so I decided to stick with this.
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.
Assuming perf/extended suites are fine, I like this, iirc there was just a test/project which crashed without some kind of stop like this originally, and the globally flag was simply expedient - definitely not complete.
@typescript-bot test this |
Heya @weswigham, I've started to run the extended test suite on this PR at 7e9a77a. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at 7e9a77a. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 7e9a77a. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 7e9a77a. You can monitor the build here. Update: The results are in! |
@weswigham Here they are:
CompilerComparison Report - main..53647
System
Hosts
Scenarios
TSServerComparison Report - main..53647
System
Hosts
Scenarios
StartupComparison Report - main..53647
System
Hosts
Scenarios
Developer Information: |
Hey @weswigham, the results of running the DT tests are ready. |
@weswigham Here are the results of running the top-repos suite comparing Everything looks good! |
…ped-type # Conflicts: # tests/baselines/reference/mappedTypeRecursiveInference.errors.txt
…ped-type # Conflicts: # tests/baselines/reference/mappedTypeRecursiveInference.errors.txt # tests/baselines/reference/mappedTypeRecursiveInference.types
@typescript-bot test this |
Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the perf test suite on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the extended test suite on this PR at ef2984b. You can monitor the build here. |
Heya @jakebailey, I've started to run the diff-based top-repos suite (tsserver) on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the tarball bundle task on this PR at ef2984b. You can monitor the build here. |
Heya @jakebailey, I've started to run the diff-based user code test suite (tsserver) on this PR at ef2984b. You can monitor the build here. Update: The results are in! |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Something interesting changed - please have a look. Details
|
@jakebailey Here are the results of running the user test suite comparing Everything looks good! |
@jakebailey Here they are:
CompilerComparison Report - main..53647
System
Hosts
Scenarios
TSServerComparison Report - main..53647
System
Hosts
Scenarios
StartupComparison Report - main..53647
System
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
Is there anything left here? This is approved and seems to be fine to my eye. |
Yes, merging it 😜 |
Just looking back at this, the variable mentioned above is from #38224; presumably, the test case from that PR still exists and is passing and I haven't been able to find a linked project which shows a perf issue being fixed by it, so I guess things seem safe? I'm not the assignee so I didn't want to click the green button, but I'm not sure how pressing / safe this one is. |
I definitely won't argue that this is a pressing PR so if you don't feel like merging this, don't feel pressured to do it. I'd consider this one to be on the safer side of things though (especially with Wes' approval) 😉 |
@jakebailey My total lack of context on the underlying changes notwithstanding, I'd still like to take the opportunity to express my appreciation of this work and hopes that the PR will be merged so I can also close the associated issue in ArkType !🙏 |
I think everyone on the review list is out; I'm gonna click the green button so we can get this tested pre-RC (and it's also a bugfix that does not seem to show any regression in extended testing); if it is a problem I'll "unclick" the green button. |
fixes #53650