Skip to content

Commit 6732851

Browse files
committed
tweak parameter name
1 parent 04953e2 commit 6732851

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20354,7 +20354,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2035420354

2035520355
function getBestMatchIndexedAccessTypeOrUndefined(source: Type, target: Type, nameType: Type) {
2035620356
if (target.flags & TypeFlags.Union) {
20357-
const best = getBestMatchingType(source, target as UnionType);
20357+
const best = getBestMatchingType(source, target as UnionType, /*matchSingleOverlappy*/ false);
2035820358
if (best) {
2035920359
return getIndexedAccessTypeOrUndefined(best, nameType);
2036020360
}
@@ -21985,7 +21985,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2198521985
}
2198621986
if (reportErrors) {
2198721987
// Elaborate only if we can find a best matching type in the target
21988-
const bestMatchingType = getBestMatchingType(source, target, isRelatedTo, /*singleOverlappy*/ true);
21988+
const bestMatchingType = getBestMatchingType(source, target, /*matchSingleOverlappy*/ true, isRelatedTo);
2198921989
if (bestMatchingType) {
2199021990
isRelatedTo(source, bestMatchingType, RecursionFlags.Target, /*reportErrors*/ true, /*headMessage*/ undefined, intersectionState);
2199121991
}
@@ -23712,11 +23712,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2371223712
return getPropertiesOfType(type).filter(targetProp => containsMissingType(getTypeOfSymbol(targetProp)));
2371323713
}
2371423714

23715-
function getBestMatchingType(source: Type, target: UnionOrIntersectionType, isRelatedTo = compareTypesAssignable, singleOverlappy = false) {
23715+
function getBestMatchingType(source: Type, target: UnionOrIntersectionType, matchSingleOverlappy: boolean, isRelatedTo = compareTypesAssignable) {
2371623716
return findMatchingDiscriminantType(source, target, isRelatedTo) ||
2371723717
findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
2371823718
findBestTypeForInvokable(source, target) ||
23719-
findMostOverlappyType(source, filterTypesForObjectLiteralMatch(source, target), singleOverlappy);
23719+
findMostOverlappyType(source, filterTypesForObjectLiteralMatch(source, target), /*matchSingle*/ matchSingleOverlappy);
2372023720
}
2372123721

2372223722
function discriminateTypeByDiscriminableItems(target: UnionType, discriminators: (readonly [() => Type, __String])[], related: (source: Type, target: Type) => boolean | Ternary) {
@@ -50924,7 +50924,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5092450924
}
5092550925
}
5092650926

50927-
function findMostOverlappyType(source: Type, target: Type, singleOverlappy: boolean) {
50927+
function findMostOverlappyType(source: Type, target: Type, matchSingle: boolean) {
5092850928
if (!(target.flags & TypeFlags.UnionOrIntersection)) {
5092950929
return target;
5093050930
}
@@ -50944,8 +50944,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5094450944
// needed to elaborate between two generic mapped types anyway.
5094550945
const len = overlap.flags & TypeFlags.Union ? countWhere((overlap as UnionType).types, isUnitType) : 1;
5094650946
if (len >= matchingCount) {
50947-
if (len > matchingCount) {
50948-
bestMatches.length = 0;
50947+
if (len > matchingCount || matchSingle) {
50948+
bestMatches.length = 0;
5094950949
}
5095050950
bestMatches = append(bestMatches, type);
5095150951
matchingCount = len;
@@ -50954,7 +50954,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5095450954
}
5095550955
}
5095650956
}
50957-
return bestMatches.length ? singleOverlappy ? last(bestMatches) : getUnionType(bestMatches) : undefined;
50957+
return bestMatches.length ? getUnionType(bestMatches) : undefined;
5095850958
}
5095950959

5096050960
function filterPrimitivesIfContainsNonPrimitive(type: UnionType) {

0 commit comments

Comments
 (0)