# 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

    138x
    138x

    138x
    3x
    3x

    135x

    135x

     // @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);
    }