MCPcopy Index your code
hub / github.com/nodejs/node / getSpreadArgumentType

Function getSpreadArgumentType

test/fixtures/snapshot/typescript.js:75548–75586  ·  view source on GitHub ↗
(args, index, argCount, restType, context, checkMode)

Source from the content-addressed store, hash-verified

75546 createTupleType([type], [8 /* ElementFlags.Variadic */]);
75547 }
75548 function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
75549 if (index >= argCount - 1) {
75550 var arg = args[argCount - 1];
75551 if (isSpreadArgument(arg)) {
75552 // We are inferring from a spread expression in the last argument position, i.e. both the parameter
75553 // and the argument are ...x forms.
75554 return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type :
75555 checkExpressionWithContextualType(arg.expression, restType, context, checkMode));
75556 }
75557 }
75558 var types = [];
75559 var flags = [];
75560 var names = [];
75561 for (var i = index; i < argCount; i++) {
75562 var arg = args[i];
75563 if (isSpreadArgument(arg)) {
75564 var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression);
75565 if (isArrayLikeType(spreadType)) {
75566 types.push(spreadType);
75567 flags.push(8 /* ElementFlags.Variadic */);
75568 }
75569 else {
75570 types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg));
75571 flags.push(4 /* ElementFlags.Rest */);
75572 }
75573 }
75574 else {
75575 var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */);
75576 var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
75577 var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */);
75578 types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
75579 flags.push(1 /* ElementFlags.Required */);
75580 }
75581 if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) {
75582 names.push(arg.tupleNameSource);
75583 }
75584 }
75585 return createTupleType(types, flags, /*readonly*/ false, ts.length(names) === ts.length(types) ? names : undefined);
75586 }
75587 function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
75588 var isJavascript = ts.isInJSFile(signature.declaration);
75589 var typeParameters = signature.typeParameters;

Callers 3

inferTypeArgumentsFunction · 0.85

Calls 14

isSpreadArgumentFunction · 0.85
isArrayLikeTypeFunction · 0.85
getIndexedAccessTypeFunction · 0.85
getNumberLiteralTypeFunction · 0.85
maybeTypeOfKindFunction · 0.85
getWidenedLiteralTypeFunction · 0.85
createTupleTypeFunction · 0.85
checkExpressionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…