packages/babel-traverse/src/path/conversion.js
function getThisBinding(thisEnvFn, inConstructor) {
  return getBinding(thisEnvFn, "this", thisBinding => {
    if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();

    const supers = new WeakSet();
    thisEnvFn.traverse({
      Function(child) {
        if (child.isArrowFunctionExpression()) return;
        child.skip();
      },
      ClassProperty(child) {
        child.skip();
      },
      CallExpression(child) {
        if (!child.get("callee").isSuper()) return;
        if (supers.has(child.node)) return;
        supers.add(child.node);

        child.replaceWithMultiple([
          child.node,
          t.assignmentExpression(
            "=",
            t.identifier(thisBinding),
            t.identifier("this"),
          ),
        ]);
      },
    });
  });
}
function getThisBinding(thisEnvFn, inConstructor) {
  return getBinding(thisEnvFn, "this", thisBinding => {
    if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();

    const supers = new WeakSet();
    thisEnvFn.traverse({
      Function(child) {
        if (child.isArrowFunctionExpression()) return;
        child.skip();
      },
      ClassProperty(child) {
        child.skip();
      },
      CallExpression(child) {
        if (!child.get("callee").isSuper()) return;
        if (supers.has(child.node)) return;
        supers.add(child.node);

        child.replaceWithMultiple([
          child.node,
          t.assignmentExpression(
            "=",
            t.identifier(thisBinding),
            t.identifier("this"),
          ),
        ]);
      },
    });
  });
}
function getThisBinding ( thisEnvFn , inConstructor ) { return getBinding ( thisEnvFn , "this" , thisBinding => { if ( ! inConstructor || ! hasSuperClass ( thisEnvFn ) ) return t . thisExpression ( ) ; const supers = new WeakSet ( ) ; thisEnvFn . traverse ( { Function ( child ) { if ( child . isArrowFunctionExpression ( ) ) return ; child . skip ( ) ; } , ClassProperty ( child ) { child . skip ( ) ; } , CallExpression ( child ) { if ( ! child . get ( "callee" ) . isSuper ( ) ) return ; if ( supers . has ( child . node ) ) return ; supers . add ( child . node ) ; child . replaceWithMultiple ( [ child . node , t . assignmentExpression ( "=" , t . identifier ( thisBinding ) , t . identifier ( "this" ) , ) , ] ) ; } , } ) ; } ) ; }
Create a binding that evaluates to the "this" of the given function.
Create a binding that evaluates to the this of the given function .