# All files / src/parser export.js

100% Statements 10/10
100% Branches 2/2
100% Functions 1/1
100% Lines 10/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27x
    27x
    27x

    167x
    167x

    167x
    5x
    5x

    162x

    162x

     // @flow
    import Syntax from "../Syntax";
    import maybeFunctionDeclaration from "./maybe-function-declaration";
    import parseTypeDef from "./type";
    import type { NodeType } from "../flow/types";
    import type Context from "./context";

    export default function parseExport(ctx: Context): NodeType {
      const node = ctx.startNode();
      ctx.eat(["export"]);

      if (ctx.token.value === "type") {
        const typedef = parseTypeDef(ctx);
        return ctx.endNode(
          {
            ...node,
            params: [typedef],
          },
          Syntax.Export
        );
      }
      const params = [maybeFunctionDeclaration(ctx)];

      return ctx.endNode({ ...node, params }, Syntax.Export);
    }