function createExternFromExportNode(names, node) {
  assert.equal(node.type, 'ExpressionStatement', 'Unknown node type');

  let comment = getLeadingBlockComment(node);
  comment = removeExportAnnotationsFromComment(comment);

  let name;
  let assignment;

  switch (node.expression.type) {
    case 'AssignmentExpression':
      // Example code: /** @export */ foo.bar = function(...) { ... };
      // Example node.expression: {
      //   operator: '=',
      //   left: {
      //     type: 'MemberExpression',
      //     object: { type: 'Identifier', name: 'foo' },
      //     property: { type: 'Identifier', name: 'bar' },
      //   }, right: {
      //     type: 'FunctionExpression', params: [ ... ], body: {...}
      //   }
      // }
      name = getIdentifierString(node.expression.left);
      assignment = createExternAssignment(name, node.expression.right,
          /* alwaysIncludeConstructor= */ true);
      break;

    case 'MemberExpression':
      // Example code: /** @export */ foo.bar;
      // Example node.expression: {
      //   object: { type: 'Identifier', name: 'foo' },
      //   property: { type: 'Identifier', name: 'bar' },
      // }
      name = getIdentifierString(node.expression);
      assignment = '';
      break;

    default:
      assert.fail('Unexpected expression type: ' + node.expression.type);
  }

  // Keep track of the names we've externed.
  names.add(name);
  // Generate the actual extern string.
  let externString = comment + '\n' + name + assignment + ';\n';

  // Find this.foo = bar in the constructor, and potentially generate externs
  // for that, too.
  if (node.expression.type == 'AssignmentExpression') {
    const rightSide = node.expression.right;

    if (rightSide.type == 'FunctionExpression' &&
        comment.includes('@constructor')) {
      externString += createExternsFromConstructor(name, rightSide);
    } else if (rightSide.type == 'ClassExpression') {
      const ctor = getClassConstructor(node.expression.right);
      if (ctor) {
        externString += createExternsFromConstructor(name, ctor);
      }
    }
  }
  return externString;
}
@param {!Set<string>} names A set of the names of exported nodes.
@param {ASTNode} node An exported node from the abstract syntax tree.
@return {string} An extern string for this node.