mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 22:32:33 -05:00
Do not mark indexed access object type comparisons as unreliable. (#54781)
This commit is contained in:
committed by
GitHub
parent
4cac28ed57
commit
f762de5220
@@ -21538,11 +21538,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// Relate components directly before falling back to constraint relationships
|
||||
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
||||
if (result = isRelatedTo((source as IndexedAccessType).objectType, (target as IndexedAccessType).objectType, RecursionFlags.Both, reportErrors)) {
|
||||
// This does _not_ generalize - specific instantiations of `S[K]` and `T[J]` may be related, even if the indexed accesses generally are not.
|
||||
// For example, `S = {x: string, a: string}`, `T = {x: string, b: string}`, `K = J = "x"`. `S` and `T` are unrelated, but the result of executing
|
||||
// `S["x"]` and `T["x"]` _are_. Given that, we have to flag the object type comparison here as "unreliable", since while the generic result can reliably
|
||||
// be used in the affirmative case, it failing is not an indicator that the structural result will not succeed.
|
||||
instantiateType((source as IndexedAccessType).objectType, reportUnreliableMapper);
|
||||
result &= isRelatedTo((source as IndexedAccessType).indexType, (target as IndexedAccessType).indexType, RecursionFlags.Both, reportErrors);
|
||||
}
|
||||
if (result) {
|
||||
|
||||
Reference in New Issue
Block a user