How to use the @babel/types.memberExpression function in @babel/types

To help you get started, we’ve selected a few @babel/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajus / flow-runtime / packages / babel-plugin-flow-runtime / src / patternMatchVisitors.js View on Github external
names.push(name);
      }
      else {
        name = names[i];
      }

      let replacement;
      let useBinding = false;

      if (i === firstRest) {
        if (param.isRest) {
          replacement = t.identifier(name);
        }
        else {
          // take the first element of the param.
          replacement = t.memberExpression(
            t.identifier(name),
            t.NumericLiteral(0),
            true
          );
          useBinding = true;
        }
      }
      else if (i > firstRest) {
        // this param appears somewhere after the first rest param
        const relativeIndex = i - firstRest;
        if (param.isRest) {
          // this is rest too so we need to slice the existing rest param
          // we only want to do this once though so we keep a cache
          if (sliceNames[i]) {
            // we've already sliced this.
            replacement = t.identifier(sliceNames[i]);
github ismail-codar / fidan / packages / deprecated-babel-plugin-transform-jsx / src / parameters.ts View on Github external
MemberExpression(path: NodePath, file) {
        //props.xxx
        if (t.isIdentifier(path.node.object)) {
          const searchName = path.node.object.name;
          const argument =
            args[
              params.findIndex(p => t.isIdentifier(p) && p.name == searchName)
            ];
          let listItem = null;
          if (
            argument &&
            t.isIdentifier(argument) &&
            check.isTrackedVariable(scope, path.node.property)
          ) {
            listItem = t.memberExpression(argument, path.node.property);
          } else if (check.isTrackedVariable(scope, path.node.object)) {
            const variableBinding = found.variableBindingInScope(
              scope,
              searchName
            );
            // assuming that local variables cannot be found in passed scope
            // if the variableBinding is found it is not local variable in this function
            if (variableBinding) {
              listItem = path.node.object;
            }
          } else if (check.isTrackedVariable(scope, path.node.property)) {
            listItem = t.memberExpression(path.node.object, path.node.property);
          }
          if (listItem && !listIncludes(list, listItem)) {
            list.push(listItem);
          }
github umijs / umi / packages / umi-build-dev / src / plugins / commands / block / sdk / flagBabelPlugin / index.ts View on Github external
i -= 1;
          }
        }
      } else {
        // root 节点没有 children,则在外面套一层
        replace(
          t.isJSXElement(node)
            ? t.jsxFragment(t.jsxOpeningFragment(), t.jsxClosingFragment(), [
                buildGUmiUIFlag({ index: 0, filename, jsx: true }) as any,
                node,
                buildGUmiUIFlag({ index: 1, filename, jsx: true }),
              ])
            : t.callExpression(
                t.memberExpression(t.identifier('React'), t.identifier('createElement')),
                [
                  t.memberExpression(t.identifier('React'), t.identifier('Fragment')),
                  t.nullLiteral(),
                  buildGUmiUIFlag({ index: 0, filename, jsx: false }),
                  node,
                  buildGUmiUIFlag({ index: 1, filename, jsx: false }),
                ],
              ),
        );
      }
    } else {
      // throw new Error(`Add umi ui flag failed, unsupported node type ${node.type}.`);
    }
  }
github parcel-bundler / parcel / src / scope-hoisting / concat.js View on Github external
let [decl] = path.getStatementParent().insertBefore(
          DEFAULT_INTEROP_TEMPLATE({
            NAME: t.identifier(name),
            MODULE: node
          })
        );

        let binding = path.scope.getBinding(getName(mod, 'exports'));
        if (binding) {
          binding.reference(decl.get('declarations.0.init'));
        }

        path.scope.registerDeclaration(decl);
      }

      return t.memberExpression(t.identifier(name), t.identifier('d'));
    }

    // if there is a CommonJS export return $id$exports.name
    if (originalName !== '*') {
      return t.memberExpression(node, t.identifier(originalName));
    }

    return node;
  }
github zhangdaren / miniprogram-to-uniapp / src / wx2uni / jsHandle.js View on Github external
function buildAssignmentWidthThis(left, right) {
	return t.assignmentExpression("=", t.memberExpression(t.thisExpression(), left), right);
}
github facebook / prepack / src / serializer / ResidualOperationSerializer.js View on Github external
_serializeCallAbstractFuncThis(
    {  }: OperationDescriptorData,
    nodes: Array
  ): BabelNodeExpression {
    let fun_args = ((nodes.slice(1): any): Array);
    return t.callExpression(t.memberExpression(nodes[0], t.identifier("call")), fun_args);
  }
github facebook / prepack / src / serializer / ResidualOperationSerializer.js View on Github external
_serializeUnknownArrayMethodPropertyCall(
    {  }: OperationDescriptorData,
    [objNode, propName, ..._args]: Array
  ): BabelNodeExpression {
    let propString = ((propName: any): BabelNodeStringLiteral).value;
    return t.callExpression(t.memberExpression(objNode, t.identifier(propString)), ((_args: any): Array));
  }
github c-zhuo / easycanvas / src / babel-plugin.js View on Github external
            .reduce((object, property) => t.memberExpression(object, property));
    };