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

Function getTypeFromObjectBindingPattern

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

Source from the content-addressed store, hash-verified

56412 }
56413 // Return the type implied by an object binding pattern
56414 function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
56415 var members = ts.createSymbolTable();
56416 var stringIndexInfo;
56417 var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
56418 ts.forEach(pattern.elements, function (e) {
56419 var name = e.propertyName || e.name;
56420 if (e.dotDotDotToken) {
56421 stringIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
56422 return;
56423 }
56424 var exprType = getLiteralTypeFromPropertyName(name);
56425 if (!isTypeUsableAsPropertyName(exprType)) {
56426 // do not include computed properties in the implied type
56427 objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */;
56428 return;
56429 }
56430 var text = getPropertyNameFromType(exprType);
56431 var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0);
56432 var symbol = createSymbol(flags, text);
56433 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
56434 symbol.bindingElement = e;
56435 members.set(symbol.escapedName, symbol);
56436 });
56437 var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo ? [stringIndexInfo] : ts.emptyArray);
56438 result.objectFlags |= objectFlags;
56439 if (includePatternInType) {
56440 result.pattern = pattern;
56441 result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
56442 }
56443 return result;
56444 }
56445 // Return the type implied by an array binding pattern
56446 function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
56447 var elements = pattern.elements;

Callers 1

Calls 9

createIndexInfoFunction · 0.85
getPropertyNameFromTypeFunction · 0.85
createSymbolFunction · 0.85
createAnonymousTypeFunction · 0.85
forEachMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…