src/com/google/javascript/jscomp/TypeCheck.java
/**
   * Recursively checks that an assignment to a destructuring pattern is valid for all the lvalues
   * contained in the pattern (including in nested patterns).
   */
Recursively checks that an assignment to a destructuring pattern is valid for all the lvalues
contained in the pattern (including in nested patterns).
Recursively checks that an assignment to a destructuring pattern is valid for all the lvalues contained in the pattern ( including in nested patterns ) .
private void checkDestructuringAssignment(
      NodeTraversal t, Node nodeToWarn, Node pattern, JSType rightType, String msg) {
    if (pattern.isArrayPattern()) {
      validator.expectAutoboxesToIterable(
          t, nodeToWarn, rightType, "array destructuring rhs must be Iterable");
    } else {
      validator.expectNotNullOrUndefined(
          t,
          nodeToWarn,
          rightType,
          "cannot destructure 'null' or 'undefined'",
          getNativeType(JSTypeNative.OBJECT_TYPE));
    }
    for (DestructuredTarget target :
        DestructuredTarget.createAllNonEmptyTargetsInPattern(typeRegistry, rightType, pattern)) {
      checkCanAssignToWithScope(
          t, nodeToWarn, target.getNode(), target.inferType(), /* info= */ null, msg);
    }
  }
private void checkDestructuringAssignment ( NodeTraversal t , Node nodeToWarn , Node pattern , JSType rightType , String msg ) { if ( pattern . isArrayPattern ( ) ) { validator . expectAutoboxesToIterable ( t , nodeToWarn , rightType , "array destructuring rhs must be Iterable" ) ; } else { validator . expectNotNullOrUndefined ( t , nodeToWarn , rightType , "cannot destructure 'null' or 'undefined'" , getNativeType ( JSTypeNative . OBJECT_TYPE ) ) ; } for ( DestructuredTarget target : DestructuredTarget . createAllNonEmptyTargetsInPattern ( typeRegistry , rightType , pattern ) ) { checkCanAssignToWithScope ( t , nodeToWarn , target . getNode ( ) , target . inferType ( ) , /* info= */ null , msg ) ; } }
Recursively checks that an assignment to a destructuring pattern is valid for all the lvalues
 contained in the pattern (including in nested patterns).
Recursively checks that an assignment to a destructuring pattern is valid for all the lvalues contained in the pattern ( including in nested patterns ) .
// TODO(b/77597706): this is not very efficient because it re-infers the types below, // which we already did once in TypeInference. don't repeat the work.