-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Handle multiple levels of substitutions and indexed accesses in getActualTypeVariable #52848
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
Conversation
@typescript-bot test this |
Heya @jakebailey, I've started to run the tarball bundle task on this PR at 58ccfee. You can monitor the build here. |
Heya @jakebailey, I've started to run the extended test suite on this PR at 58ccfee. You can monitor the build here. |
Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 58ccfee. You can monitor the build here. |
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 58ccfee. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 58ccfee. 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 (tsserver) on this PR at 58ccfee. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite (tsserver) on this PR at 58ccfee. 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 58ccfee. 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 Everything looks good! |
Heya @jakebailey, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
@jakebailey Here are the results of running the user test suite comparing Everything looks good! |
@jakebailey Here they are:
CompilerComparison Report - main..52848
System
Hosts
Scenarios
TSServerComparison Report - main..52848
System
Hosts
Scenarios
StartupComparison Report - main..52848
System
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Detailspuppeteer/puppeteer
|
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
Fixes #49556
#48837 added a special case to
getConditionalFlowTypeOfType
that adds a constraint ofnumber | `${number}`
toK
in a homomorphic mapped type like{ [K in keyof T]: XXX }
whenT
is a tuple or array. This resulted in a substitution within the indexed access to account for the constraint.getActualTypeVariable
was already equipped to handle a substitution within an indexed access, so most things worked fine. All good so far.However, in inference, we end up with the opposite; there's an indexed access within a substitution, but
getActualTypeVariable
didn't handle that case. So, when inference went to try and add an inference, it'dgetActualTypeVariable
the target, but then fail to find the type variable in the inference context because the intended type variable was still one more level deep.So, let
getActualTypeVariable
recurse on substitutions too, ensuring the inference gets added, allowing the code in #49556 to continue working as it did before TS 4.7.(To find this, I just partially reverted #48837 and compared the inference by stepping through; in the good case, I had the right inference and it added it, but in the bad case, it still had the right inference but couldn't find where to add it; comparing the
__debugTypeToString()
showed that they looked the same, and I just tried runninggetActualTypeVariable
again and surprise, they had the same ID.)