How to use the isBooleanLiteral function from @babel/types

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

301
302
303
304
305
306
307
308
309
310
311
traverse(ast, {
    WhileStatement: {
        exit(path) {
            let { node } = path;
            // 判断是否是目标节点
            if (!(t.isUnaryExpression(node.test) || t.isBooleanLiteral(node.test))) return; // 判断类型:   while(!![])   while(true)
            if (!(node.test.value || node.test.prefix)) return; // 判断值: while中的值是否为true
            if (!t.isBlockStatement(node.body)) return; // 判断是否是块语句


            // 检查块语句中的内容是否满足要求
fork icon5
star icon14
watch icon1

+ 2 other calls in file

34
35
36
37
38
39
40
41
42
43

// 获取Props默认值
function getDefaultVal(node) {
  if (
    types.isRegExpLiteral(node) ||
    types.isBooleanLiteral(node) ||
    types.isNumericLiteral(node) ||
    types.isStringLiteral(node)
  ) {
    return node.value
fork icon2
star icon8
watch icon2

+ 5 other calls in file

32
33
34
35
36
37
38
39
40
41
    }
}

// 获取Props默认值
function getDefaultVal(node) {
    if (types.isRegExpLiteral(node) || types.isBooleanLiteral(node) || types.isNumericLiteral(node) || types.isStringLiteral(node)) {
        return node.value
    } else if (types.isFunctionExpression(node) || types.isArrowFunctionExpression(node) || types.isObjectMethod(node)) {
        try {
            let code = generate.default(types.isObjectMethod(node) ? node.body : node).code
fork icon6
star icon7
watch icon0

290
291
292
293
294
295
296
297
298
299
300
301
  (declaration.id.name === 'utils' ||
    argZeroEquals(declaration.init.arguments, './utils'))


const node6Stuff = declaration =>
  declaration.id.name === 'asyncawait' &&
  btypes.isBooleanLiteral(declaration.init)


const isNode6InterOpIt = path =>
  btypes.isConditionalExpression(path.node.callee) &&
  btypes.isIdentifier(path.node.callee.test, { name: 'asyncawait' })
fork icon0
star icon15
watch icon1

25
26
27
28
29
30
31
32
33
34
}
const expr = parseExpression(str)
if (
  t.isStringLiteral(expr) ||
  t.isNumericLiteral(expr) ||
  t.isBooleanLiteral(expr) ||
  t.isNullLiteral(expr)
) {
  return false
}
fork icon0
star icon2
watch icon1

+ 25 other calls in file

10
11
12
13
14
15
16
17
18
19
 * @param {JSXElement|String|Number} el
 */
function parseElement(el) {
  if (t.isStringLiteral(el) || t.isNumericLiteral(el)) {
    return parseBaseStructure(el);
  } else if (t.isNullLiteral(el) || t.isBooleanLiteral(el) || t.isIdentifier(el, { name: 'undefined' } )) {
    return null;
  } else if (t.isArrayExpression(el)) {
    return parseElementArray(el);
  } else {
fork icon663
star icon0
watch icon2

+ 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)