mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Remove assignability cases in getNarrowedType + an isArray improvement for readonly arrays (#39258)
* Explore using a different isArray declaration * Add tests and the new isArray definition * Baseline updates * Upda the isArray type
This commit is contained in:
1 parent
1d2278be05
commit
fa89ce6158
23 files changed
+700
-63
No files matched your search
@@ -21984,15 +21984,11 @@ namespace ts {
|
||||
return assignableType;
|
||||
}
|
||||
}
|
||||
// If the candidate type is a subtype of the target type, narrow to the candidate type.
|
||||
// Otherwise, if the target type is assignable to the candidate type, keep the target type.
|
||||
// Otherwise, if the candidate type is assignable to the target type, narrow to the candidate
|
||||
// type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
|
||||
// two types.
|
||||
return isTypeSubtypeOf(candidate, type) ? candidate :
|
||||
isTypeAssignableTo(type, candidate) ? type :
|
||||
isTypeAssignableTo(candidate, type) ? candidate :
|
||||
getIntersectionType([type, candidate]);
|
||||
|
||||
// If the candidate type is a subtype of the target type, narrow to the candidate type,
|
||||
// if the target type is a subtype of the candidate type, narrow to the target type,
|
||||
// otherwise, narrow to an intersection of the two types.
|
||||
return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
|
||||
}
|
||||
|
||||
function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
|
||||
|
||||
Reference in new issue
Block a user