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
![yandex profile picture](/yandex.png?size=40)
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)
+ 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) ) {
GitHub: menhal/anu
![menhal profile picture](/menhal.png?size=40)
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';
+ 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) }
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) &&
@babel/types.identifier is the most popular function in @babel/types (20936 examples)