mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-08 18:11:45 -06:00
Compute per-element contextual type in getSpreadArgumentType
This commit is contained in:
parent
de76d55ddd
commit
fca46bb706
@ -20264,15 +20264,15 @@ namespace ts {
|
||||
getArrayifiedType(checkExpressionWithContextualType((<SpreadElement>arg).expression, restType, context, CheckMode.Normal));
|
||||
}
|
||||
}
|
||||
const contextualType = getIndexedAccessType(restType, numberType);
|
||||
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, TypeFlags.Primitive | TypeFlags.Index);
|
||||
const types = [];
|
||||
let spreadIndex = -1;
|
||||
for (let i = index; i < argCount; i++) {
|
||||
const contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
|
||||
const argType = checkExpressionWithContextualType(args[i], contextualType, context, CheckMode.Normal);
|
||||
if (spreadIndex < 0 && isSpreadArgument(args[i])) {
|
||||
spreadIndex = i - index;
|
||||
}
|
||||
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, TypeFlags.Primitive | TypeFlags.Index);
|
||||
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
|
||||
}
|
||||
return spreadIndex < 0 ?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user