How to use the isNewExpression function from @babel/types
Find comprehensive JavaScript @babel/types.isNewExpression code examples handpicked from public code repositorys.
181 182 183 184 185 186 187 188 189 190
} let name = getNameFromId(id); if (name == null) { if (t.isCallExpression(parent) || t.isNewExpression(parent)) { // foo(function () {}) const argIndex = parent.arguments.indexOf(node); if (argIndex !== -1) { const calleeName = getNameFromId(parent.callee);
+ 5 other calls in file
GitHub: omarjuice/algo-viz
![omarjuice profile picture](/omarjuice.png?size=40)
76 77 78 79 80 81 82 83 84
funcName = path.node.id.name } else if (t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)) { funcName = path.parent.id.name } else if (t.isObjectProperty(path.parent) && !path.parent.computed) { funcName = 'method:' + path.parent.key.name } else if (t.isCallExpression(path.parent) || t.isNewExpression(path.parent)) { if (t.isMemberExpression(path.parent.callee)) { const idx = path.parent.arguments.indexOf(path.node) funcName = t.stringLiteral(`callback-${idx}`)
+ 21 other calls in file
24 25 26 27 28 29 30 31 32 33
&& t.isObjectExpression(path.node.right) ) { const properties = path.node.right.properties .filter(p => t.isProperty(p)) .filter(p => t.isIdentifier(p.key)) .filter(p => t.isNewExpression(p.value)); properties.forEach(p => this.hooks.push({ name: p.key.name, line: p.loc.start.line }));
+ 7 other calls in file
29 30 31 32 33 34 35 36 37 38
traverse(targetSource.ast, { CallExpression: (path) => { if ( t.isMemberExpression(path.node.callee) && t.isNewExpression(path.node.callee.object) && t.isIdentifier(path.node.callee.object.callee) && path.node.callee.object.callee.name === 'Vue' ) { path.insertBefore(vuePlugins);
+ 3 other calls in file
206 207 208 209 210 211 212 213 214 215
// TODO remove duplication in newexp and callexp and check arguments type function processArgument(argumentPath, statement) { if ( (statement && (t.isCallExpression(argumentPath.node) || t.isNewExpression(argumentPath.node) || t.isIdentifier(argumentPath.node))) || t.isMemberExpression(argumentPath.node) || t.isLiteral(argumentPath.node) || t.isObjectExpression(argumentPath.node) ||
+ 28 other calls in file
332 333 334 335 336 337 338 339 340 341 342 343
function getNamePartsFromId(id) { if (!id) { return []; } if (t.isCallExpression(id) || t.isNewExpression(id)) { return getNamePartsFromId(id.callee); } if (t.isTypeCastExpression(id)) {
+ 521 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)