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;
0
31
2
+ 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(); });
4
8
4
+ 3 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)