How to use the newExpression function from babel-types

Find comprehensive JavaScript babel-types.newExpression code examples handpicked from public code repositorys.

97
98
99
100
101
102
103
104
105
106
null,
[],
t.blockStatement(
  [
    t.returnStatement(
      t.newExpression(
        path.node.declarations[0].init.callee,
        path.node.declarations[0].init.arguments
      )
    )
fork icon49
star icon47
watch icon12

+ 43 other calls in file

56
57
58
59
60
61
62
63
64
65
if (firstSymbol.endsWith('.')) {
  const args = node.values
    .slice(1, node.values.length)
    .map(arg => toFlat(translate(arg)));
  return [
    t.newExpression(t.identifier(resolveSymbol(firstSymbol)), args),
  ];
}
// (foo bar baz) -> foo(bar, baz)
const args = node.values
fork icon1
star icon10
watch icon2

+ 29 other calls in file

24
25
26
27
28
29
30
31
32
const statements = [];
statements.push(
  t.variableDeclaration('var', [
    t.variableDeclarator(
      t.identifier('implementedProperties'),
      t.newExpression(t.identifier('Set'), [])
    ),
  ])
);
fork icon59
star icon0
watch icon1

52
53
54
55
56
57
58
59
60
61
    t.binaryExpression('-', dateNow(), loopStart),
    t.numericLiteral(maxLoopTimeMs),
  ),
),
t.throwStatement(
  t.newExpression(t.identifier('RangeError'), [
    t.stringLiteral(
      'Potential infinite loop. You can disable this from settings.',
    ),
  ]),
fork icon4
star icon0
watch icon0

+ 3 other calls in file

22
23
24
25
26
27
28
29
30
31
  );
});
const typeDefinition = t.variableDeclaration('const', [
  t.variableDeclarator(
    t.identifier(name),
    t.newExpression(t.identifier(gt.GraphQLUnionType), [
      t.objectExpression([
        t.objectProperty(
          t.identifier('name'),
          t.stringLiteral(capitalizeWord(name)),
fork icon0
star icon3
watch icon2

+ 5 other calls in file

46
47
48
49
50
51
52
53
54
55
    ]);
  });
}

entityDefinition({ description }) {
  return t.newExpression(
    t.memberExpression(t.identifier('normalizr'), t.identifier('Entity')),
    [
      t.stringLiteral(description.asCollection),
      t.objectExpression([]),
fork icon0
star icon0
watch icon2

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)