Method()

in packages/transform/src/visit.js [17:45]


  Method(path, state) {
    let node = path.node;

    if (!shouldRegenerate(node, state)) return;

    const container = t.functionExpression(
      null,
      [],
      t.cloneNode(node.body, false),
      node.generator,
      node.async,
    );

    path.get("body").set("body", [
      t.returnStatement(
        t.callExpression(container, []),
      ),
    ]);

    // Regardless of whether or not the wrapped function is a an async method
    // or generator the outer function should not be
    node.async = false;
    node.generator = false;

    // Unwrap the wrapper IIFE's environment so super and this and such still work.
    path
      .get("body.body.0.argument.callee")
      .unwrapFunctionEnvironment();
  },