src/com/google/javascript/jscomp/TypeCheck.java
/**
   * Visits a VAR node.
   *
   * @param t The node traversal object that supplies context, such as the
   * scope chain to use in name lookups as well as error reporting.
   * @param n The node being visited.
   */
Visits a VAR node.
@param t The node traversal object that supplies context, such as the
scope chain to use in name lookups as well as error reporting.
@param n The node being visited.
Visits a VAR node . @param t The node traversal object that supplies context such as the scope chain to use in name lookups as well as error reporting . @param n The node being visited .
private void visitVar(NodeTraversal t, Node n) {
    if (n.getParent().isForOf() || n.getParent().isForIn()) {
      return;
    }
    JSDocInfo varInfo = n.hasOneChild() ? n.getJSDocInfo() : null;
    for (Node child : n.children()) {
      if (child.isName()) {
        Node value = child.getFirstChild();
        if (value != null) {
          JSType valueType = getJSType(value);
          JSDocInfo info = child.getJSDocInfo();
          if (info == null) {
            info = varInfo;
          }
          checkEnumAlias(t, info, valueType, value);
          checkCanAssignToWithScope(t, value, child, valueType, info, "initializing variable");
        }
      } else {
        checkState(child.isDestructuringLhs(), child);
        Node name = child.getFirstChild();
        Node value = child.getSecondChild();
        JSType valueType = getJSType(value);
        checkCanAssignToWithScope(
            t, child, name, valueType, /* info= */ null, "initializing variable");
      }
    }
  }
private void visitVar ( NodeTraversal t , Node n ) { if ( n . getParent ( ) . isForOf ( ) || n . getParent ( ) . isForIn ( ) ) { return ; } JSDocInfo varInfo = n . hasOneChild ( ) ? n . getJSDocInfo ( ) : null ; for ( Node child : n . children ( ) ) { if ( child . isName ( ) ) { Node value = child . getFirstChild ( ) ; if ( value != null ) { JSType valueType = getJSType ( value ) ; JSDocInfo info = child . getJSDocInfo ( ) ; if ( info == null ) { info = varInfo ; } checkEnumAlias ( t , info , valueType , value ) ; checkCanAssignToWithScope ( t , value , child , valueType , info , "initializing variable" ) ; } } else { checkState ( child . isDestructuringLhs ( ) , child ) ; Node name = child . getFirstChild ( ) ; Node value = child . getSecondChild ( ) ; JSType valueType = getJSType ( value ) ; checkCanAssignToWithScope ( t , child , name , valueType , /* info= */ null , "initializing variable" ) ; } } }
Visits a VAR node.
Visits a VAR node .
// Handle var declarations in for-of loops separately from regular var declarations. // TODO(nicksantos): Fix this so that the doc info always shows up // on the NAME node. We probably want to wait for the parser // merge to fix this.