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

Function getTypeOfAssignmentPattern

test/fixtures/snapshot/typescript.js:86622–86651  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

86620 // [ a ] from
86621 // [a] = [ some array ...]
86622 function getTypeOfAssignmentPattern(expr) {
86623 ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */);
86624 // If this is from "for of"
86625 // for ( { a } of elems) {
86626 // }
86627 if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
86628 var iteratedType = checkRightHandSideOfForOf(expr.parent);
86629 return checkDestructuringAssignment(expr, iteratedType || errorType);
86630 }
86631 // If this is from "for" initializer
86632 // for ({a } = elems[0];.....) { }
86633 if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) {
86634 var iteratedType = getTypeOfExpression(expr.parent.right);
86635 return checkDestructuringAssignment(expr, iteratedType || errorType);
86636 }
86637 // If this is from nested object binding pattern
86638 // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
86639 if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) {
86640 var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
86641 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
86642 var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
86643 return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
86644 }
86645 // Array literal assignment - array destructuring pattern
86646 var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
86647 // [{ property1: p1, property2 }] = elems;
86648 var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
86649 var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
86650 return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
86651 }
86652 // Gets the property symbol corresponding to the property in destructuring assignment
86653 // 'property1' from
86654 // for ( { property1: a } of elems) {

Callers 2

createTypeCheckerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…