Skip to content

Commit fca46bb

Browse files
committed
Compute per-element contextual type in getSpreadArgumentType
1 parent de76d55 commit fca46bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20264,15 +20264,15 @@ namespace ts {
2026420264
getArrayifiedType(checkExpressionWithContextualType((<SpreadElement>arg).expression, restType, context, CheckMode.Normal));
2026520265
}
2026620266
}
20267-
const contextualType = getIndexedAccessType(restType, numberType);
20268-
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, TypeFlags.Primitive | TypeFlags.Index);
2026920267
const types = [];
2027020268
let spreadIndex = -1;
2027120269
for (let i = index; i < argCount; i++) {
20270+
const contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
2027220271
const argType = checkExpressionWithContextualType(args[i], contextualType, context, CheckMode.Normal);
2027320272
if (spreadIndex < 0 && isSpreadArgument(args[i])) {
2027420273
spreadIndex = i - index;
2027520274
}
20275+
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, TypeFlags.Primitive | TypeFlags.Index);
2027620276
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
2027720277
}
2027820278
return spreadIndex < 0 ?

0 commit comments

Comments
 (0)