How to use the isNullLiteral function from @babel/types

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

189
190
191
192
193
194
195
196
197
198
 * 判断是否是null表达式
 * @param node
 * @return {Boolean}
 */
function isNullLiteral(node) {
  return t.isNullLiteral(node) || t.isIdentifier(node, { name: 'null' });
}

/**
 * 弃用指令错误
fork icon13
star icon88
watch icon4

+ 3 other calls in file

125
126
127
128
129
130
131
132
133
134
      btypes.identifier('false')
    ),
    [actual]
  )
} else if (
  btypes.isNullLiteral(expected) ||
  btypes.isIdentifier(expected, { name: 'undefined' })
) {
  return btypes.callExpression(
    btypes.memberExpression(
fork icon0
star icon15
watch icon1

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

+ 25 other calls in file

85
86
87
88
89
90
91
92
93
94
  }
}

if (
  recursionDepth > 0 &&
  (t.isBooleanLiteral(node) || t.isNullLiteral(node)) &&
  ((isRight && start == node.start) || (isLeft && start == node.end))
) {
  return [node.start, node.end];
}
fork icon4
star icon0
watch icon1

+ 13 other calls in file

268
269
270
271
272
273
274
275
276
277
278
    return nodes.concat(traverseExpr(exprNode, state))
  }, [])
}


function genSlotNode (slotName, slotNode, fallbackNodes, state) {
  if (!fallbackNodes || t.isNullLiteral(fallbackNodes)) {
    return slotNode
  }
  // 支付宝小程序默认插槽为 $default
  if (state.options.platform.name === 'mp-alipay') {
fork icon0
star icon1
watch icon1

+ 5 other calls in file

68
69
70
71
72
73
74
75
76
77
    t.stringLiteral(value)
);
const args = path.node.arguments;
if (
    !args[1] ||
    t.isNullLiteral(args[1]) ||
    isUndefinedIdentifier(args[1])
) {
    args[1] = t.objectExpression([]);
}
fork icon0
star icon1
watch icon1

+ 10 other calls in file

119
120
121
122
123
124
125
126
127
128
}]
if (
  !(
    (t.isCallExpression(conditionalExprNode.alternate) &&
      t.isIdentifier(conditionalExprNode.alternate.callee) &&
      conditionalExprNode.alternate.callee.name === '_e') || t.isNullLiteral(conditionalExprNode.alternate)
  )
) {
  // test?_c():_e()
  ret.push({
fork icon0
star icon0
watch icon502

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