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

To help you get started, we’ve selected a few @babel/core 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 alan-ai / alan-sdk-reactnative / testtools / node_modules / @babel / plugin-transform-block-scoping / lib / index.js View on Github external
state.returnStatements.forEach(returnStatement => {
        returnStatement.insertBefore(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName))));
      });
      fn.body.body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName))));
github alan-ai / alan-sdk-reactnative / testtools / node_modules / @babel / plugin-proposal-optional-chaining / lib / index.js View on Github external
function isSimpleMemberExpression(expression) {
    expression = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(expression);
    return _core.types.isIdentifier(expression) || _core.types.isSuper(expression) || _core.types.isMemberExpression(expression) && !expression.computed && isSimpleMemberExpression(expression.object);
  }
github polakowo / datadocs / website / node_modules / @babel / plugin-transform-block-scoping / lib / tdz.js View on Github external
        path.replaceWithMultiple(nodes.map(n => _core.types.expressionStatement(n)));
      }
github maxdenaro / maxgraph-youtube-source / JS-плагины №7. Новое подключение swiper.js через npm / node_modules / @babel / plugin-transform-classes / lib / transformClass.js View on Github external
function pushBody() {
    const classBodyPaths = classState.path.get("body.body");

    for (const path of classBodyPaths) {
      const node = path.node;

      if (path.isClassProperty()) {
        throw path.buildCodeFrameError("Missing class properties transform.");
      }

      if (node.decorators) {
        throw path.buildCodeFrameError("Method has decorators, put the decorator plugin before the classes one.");
      }

      if (_core.types.isClassMethod(node)) {
        const isConstructor = node.kind === "constructor";
        const replaceSupers = new _helperReplaceSupers.default({
          methodPath: path,
          objectRef: classState.classRef,
          superRef: classState.superName,
          isLoose: classState.isLoose,
          file: classState.file
        });
        replaceSupers.replace();
        const superReturns = [];
        path.traverse(_core.traverse.visitors.merge([_helperReplaceSupers.environmentVisitor, {
          ReturnStatement(path) {
            if (!path.getFunctionParent().isArrowFunctionExpression()) {
              superReturns.push(path);
            }
          }
github jarden-digital / react-native-pincode / node_modules / @babel / plugin-transform-for-of / lib / index.js View on Github external
function pushComputedPropsSpec(path, file) {
    var node = path.node,
        scope = path.scope,
        parent = path.parent;
    var left = node.left;
    var declar;
    var stepKey = scope.generateUid("step");

    var stepValue = _core.types.memberExpression(_core.types.identifier(stepKey), _core.types.identifier("value"));

    if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) {
      declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue));
    } else if (_core.types.isVariableDeclaration(left)) {
      declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]);
    } else {
      throw file.buildCodeFrameError(left, "Unknown node type " + left.type + " in ForStatement");
    }

    var template = buildForOf({
      ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
      ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"),
      ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
      ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
      STEP_KEY: _core.types.identifier(stepKey),
      OBJECT: node.right
github maxdenaro / maxgraph-youtube-source / JS-плагины №7. Новое подключение swiper.js через npm / node_modules / @babel / plugin-transform-classes / lib / transformClass.js View on Github external
if (staticProps) {
        staticProps = defineMap.toComputedObjectFromClass(staticProps);
      }

      let args = [_core.types.cloneNode(classState.classRef), _core.types.nullLiteral(), _core.types.nullLiteral()];
      if (instanceProps) args[1] = instanceProps;
      if (staticProps) args[2] = staticProps;
      let lastNonNullIndex = 0;

      for (let i = 0; i < args.length; i++) {
        if (!_core.types.isNullLiteral(args[i])) lastNonNullIndex = i;
      }

      args = args.slice(0, lastNonNullIndex + 1);
      body.push(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper("createClass"), args)));
    }

    clearDescriptors();
  }
github maxdenaro / maxgraph-youtube-source / JS-плагины №7. Новое подключение swiper.js через npm / node_modules / @babel / plugin-transform-classes / lib / transformClass.js View on Github external
}

    if (hasConstructor) return;
    let params, body;

    if (classState.isDerived) {
      const constructor = _core.template.expression.ast`
        (function () {
          super(...arguments);
        })
      `;
      params = constructor.params;
      body = constructor.body;
    } else {
      params = [];
      body = _core.types.blockStatement([]);
    }

    classState.path.get("body").unshiftContainer("body", _core.types.classMethod("constructor", _core.types.identifier("constructor"), params, body));
  }
github elastic / eui / scripts / babel / proptypes-from-ts-props / index.js View on Github external
function areExpressionsIdentical(a, b) {
  const aCode = babelCore.transformFromAst(
    babelCore.types.program([
      babelCore.types.expressionStatement(
        babelCore.types.removeComments(babelCore.types.cloneDeep(a))
      ),
    ])
  ).code;
  const bCode = babelCore.transformFromAst(
    babelCore.types.program([
      babelCore.types.expressionStatement(
        babelCore.types.removeComments(babelCore.types.cloneDeep(b))
      ),
    ])
  ).code;
  return aCode === bCode;
}