Treat array literal contextually typed by homomorphic mapped types as in tuple context (#56555)

This commit is contained in:
Mateusz Burzyński authored and GitHub committed 2023-12-13 15:12:38 -08:00
1 parent b527b9059a
commit 2c7162143b
5 files changed
+328 -2

No files matched your search

+2 -1
View File
@@ -31053,7 +31053,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const inDestructuringPattern = isAssignmentTarget(node);
const inConstContext = isConstContext(node);
const contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
const inTupleContext = isSpreadIntoCallOrNew(node) || !!contextualType && someType(contextualType, isTupleLikeType);
const inTupleContext = isSpreadIntoCallOrNew(node) || !!contextualType && someType(contextualType, t => isTupleLikeType(t) || isGenericMappedType(t) && !t.nameType && !!getHomomorphicTypeVariable(t.target as MappedType || t));
let hasOmittedExpression = false;
for (let i = 0; i < elementCount; i++) {
const e = elements[i];