How to use the assertStringLiteral function from babel-types

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

99
100
101
102
103
104
105
106

function extractRequiredModule (node) {
  t.assertCallExpression(node);
  t.assertIdentifier(node.callee, { name: 'require' });
  var arg = node.arguments[0];
  t.assertStringLiteral(arg);
  return arg.value;
}
fork icon11
star icon0
watch icon2

+ 7 other calls in file

72
73
74
75
76
77
78
79
80
81
    baz: 1
});

t.is(ast.properties.length, 2);
babelTypes.assertStringLiteral(ast.properties[0].key, { value: 'foo' });
babelTypes.assertStringLiteral(ast.properties[0].value, { value: 'bar' });
babelTypes.assertStringLiteral(ast.properties[1].key, { value: 'baz' });
babelTypes.assertNumericLiteral(ast.properties[1].value, { value: 1 });

t.pass();
fork icon4
star icon0
watch icon0

+ 35 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

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