How to use the assertNumericLiteral function from @babel/types

Find comprehensive JavaScript @babel/types.assertNumericLiteral code examples handpicked from public code repositorys.

13
14
15
16
17
18
19
20
21
 * @type {import('tscm/macro').Macro}
 */
module.exports.add = function add({ node }) {
  assert.equal(node.arguments.length, 2, 'Expected two arguments');
  const [firstNumber, secondNumber] = node.arguments;
  t.assertNumericLiteral(firstNumber);
  t.assertNumericLiteral(secondNumber);

  const sum = firstNumber.value + secondNumber.value;
fork icon0
star icon31
watch icon2

+ 39 other calls in file

74
75
76
77
78
79
80
81
82

    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 icon8
watch icon4

+ 3 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 (20936 examples)