mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Reduce intersections that aren't assignable to their constituents to never
This commit is contained in:
@@ -12387,6 +12387,11 @@ namespace ts {
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function getAssignableIntersectionType(type1: Type, type2: Type) {
|
||||
const type = getIntersectionType([type1, type2]);
|
||||
return isTypeAssignableTo(type, type1) && isTypeAssignableTo(type, type2) ? type : neverType;
|
||||
}
|
||||
|
||||
function createIndexType(type: InstantiableType | UnionOrIntersectionType, stringsOnly: boolean) {
|
||||
const result = <IndexType>createType(TypeFlags.Index);
|
||||
result.type = type;
|
||||
@@ -20678,7 +20683,7 @@ namespace ts {
|
||||
return isTypeSubtypeOf(candidate, type) ? candidate :
|
||||
isTypeAssignableTo(type, candidate) ? type :
|
||||
isTypeAssignableTo(candidate, type) ? candidate :
|
||||
getIntersectionType([type, candidate]);
|
||||
getAssignableIntersectionType(type, candidate);
|
||||
}
|
||||
|
||||
function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
|
||||
|
||||
Reference in New Issue
Block a user