Always substitute indexed generic mapped type when getting constraint from indexed access#53066
Conversation
… from indexed access
|
|
||
| function getConstraintFromIndexedAccess(type: IndexedAccessType) { | ||
| if (isMappedTypeGenericIndexedAccess(type)) { | ||
| if (isMappedTypeGenericIndexedAccess(type) || isGenericMappedType(type.objectType)) { |
There was a problem hiding this comment.
If the indexed access is allowed - then I think it's always safe to substitute as when the indexType is invalid then the error is reported elsewhere anyway.
|
@typescript-bot test this |
|
Heya @weswigham, I've started to run the extended test suite on this PR at 20c9d3a. You can monitor the build here. |
|
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 20c9d3a. You can monitor the build here. Update: The results are in! |
|
Heya @weswigham, I've started to run the perf test suite on this PR at 20c9d3a. 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 20c9d3a. You can monitor the build here. Update: The results are in! |
|
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! |
|
@weswigham Here they are:
CompilerComparison Report - main..53066
System
Hosts
Scenarios
TSServerComparison Report - main..53066
System
Hosts
Scenarios
StartupComparison Report - main..53066
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@Andarist @weswigham Stumbled on this PR that I hadn't seen before. Something is not right here: type Remap<K extends string> = {
[P in K as `_${P}`]: P;
};
type Key = "foo" | "bar" | "baz";
function qq1<K extends string>(obj: Remap<K>, key: keyof Remap<K>) {
let s: `_${string}` = obj[key]; // Error expected here
}
function qq2(obj: Remap<Key>, key: keyof Remap<Key>) {
let s: `_${string}` = obj[key]; // Error (as expected)
}I think your comment here is really only true when the name type isn't a remapping. |
…nstraint from indexed access (microsoft#53066)" This reverts commit abb4052.
fixes #50030