function finishNode(node, type) {
    node.type = type;
    node.end = lastEnd;
    if (options.locations) {
      node.loc.end = lastEndLoc;
    }
    if (options.ranges) {
      node.range[1] = lastEnd;
    }
    return node;
  }
Finish an AST node, adding `type` and `end` properties.

@param {!node_t} node
@param {string} type
@returns {!node_t}