How to use the isConditionalExpression function from @babel/types

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

46
47
48
49
50
51
52
53
54
55
const isReturned = (p) => {
  const { parent } = p

  if (
    t.isCallExpression(parent) ||
    t.isConditionalExpression(parent) ||
    t.isSequenceExpression(parent) ||
    t.isLogicalExpression(parent)
  ) {
    return isReturned(p.parentPath)
fork icon10
star icon44
watch icon10

+ 17 other calls in file

90
91
92
93
94
95
96
97
98
99
  // No handling for ^^ right now
} else if ( t.isFunctionExpression(path.node.init) ){
  // No handling for ^^ right now
} else if ( t.isUnaryExpression(path.node.init) ){
  // No handling for ^^ right now
} else if ( t.isConditionalExpression(path.node.init) ){
  // No handling for ^^ right now
} else if ( t.isLogicalExpression(path.node.init) ){
  // No handling for ^^ right now
} else if ( t.isObjectExpression(path.node.init) ) {
fork icon1
star icon6
watch icon7

160
161
162
163
164
165
166
167
168
169
    return state.file.opts.anu;
},
isLoopMap(astPath: any) {
    if (
        t.isJSXExpressionContainer(astPath.parentPath) ||
        t.isConditionalExpression(astPath.parentPath) ||
        t.isLogicalExpression(astPath.parentPath)
    ) {
        var callee = astPath.node.callee;
        return callee.type == 'MemberExpression' && callee.property.name === 'map';
fork icon330
star icon0
watch icon0

+ 3 other calls in file

722
723
724
725
726
727
728
729
730
731
function conditionalExpToIfStatement (ast) {
    traverse(ast, {
        noScope: true,
        ExpressionStatement (path) {
            let exp = path.node.expression
            if (exp && t.isConditionalExpression(exp)) {
                //三元表达式转if表达式
                if (t.isConditionalExpression(exp.consequent)) {
                    conditionalExpToIfStatement(exp.consequent)
                }
fork icon220
star icon0
watch icon0

293
294
295
296
297
298
299
300
301
302
303
304
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' })


const isInverseExpect = path =>
  btypes.isMemberExpression(path.node.callee) &&
fork icon0
star icon15
watch icon1

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)