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

Function getTypeFromArrayBindingPattern

test/fixtures/snapshot/typescript.js:56446–56463  ·  view source on GitHub ↗
(pattern, includePatternInType, reportErrors)

Source from the content-addressed store, hash-verified

56444 }
56445 // Return the type implied by an array binding pattern
56446 function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
56447 var elements = pattern.elements;
56448 var lastElement = ts.lastOrUndefined(elements);
56449 var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined;
56450 if (elements.length === 0 || elements.length === 1 && restElement) {
56451 return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType;
56452 }
56453 var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
56454 var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1;
56455 var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; });
56456 var result = createTupleType(elementTypes, elementFlags);
56457 if (includePatternInType) {
56458 result = cloneTypeReference(result);
56459 result.pattern = pattern;
56460 result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
56461 }
56462 return result;
56463 }
56464 // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
56465 // and without regard to its context (i.e. without regard any type annotation or initializer associated with the
56466 // declaration in which the binding pattern is contained). For example, the implied type of [x, y] is [any, any]

Callers 1

Calls 6

createIterableTypeFunction · 0.85
hasDefaultValueFunction · 0.85
createTupleTypeFunction · 0.85
cloneTypeReferenceFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…