mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 01:34:55 -06:00
Avoid doing subtype reduction on arrays when contextually typed by array types.
This commit is contained in:
parent
e3d6189e3a
commit
6e6fbdabb1
@ -26175,8 +26175,9 @@ namespace ts {
|
||||
if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) {
|
||||
return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext));
|
||||
}
|
||||
const unionReductionStrategy = contextualType && isArrayType(contextualType) ? UnionReduction.None : UnionReduction.Subtype;
|
||||
return createArrayLiteralType(createArrayType(elementTypes.length ?
|
||||
getUnionType(sameMap(elementTypes, (t, i) => elementFlags[i] & ElementFlags.Variadic ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t), UnionReduction.Subtype) :
|
||||
getUnionType(sameMap(elementTypes, (t, i) => elementFlags[i] & ElementFlags.Variadic ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t), unionReductionStrategy) :
|
||||
strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user