How to use the isConditionalExpression function from @babel/types
Find comprehensive JavaScript @babel/types.isConditionalExpression code examples handpicked from public code repositorys.
GitHub: yandex/reselector
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)
10
44
10
+ 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) ) {
1
6
7
GitHub: menhal/anu
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';
330
0
0
+ 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) }
220
0
0
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) &&
0
15
1
@babel/types.identifier is the most popular function in @babel/types (20936 examples)