How to use the arrowFunctionExpression function from @babel/types
Find comprehensive JavaScript @babel/types.arrowFunctionExpression code examples handpicked from public code repositorys.
GitHub: fecym/ast-share

5 6 7 8 9 10 11 12 13 14
const fnToArrowPlugin = { visitor: { FunctionExpression(path) { const { params, body } = path.node const arrowFunctionExpression = t.arrowFunctionExpression(params, body) path.replaceWith(arrowFunctionExpression) } } }
+ 3 other calls in file
GitHub: jackromo888/octicons

53 54 55 56 57 58 59 60 61 62
t.callExpression(t.identifier('createIconComponent'), [ // The name of the generated icon t.stringLiteral(name), // The className used on the underlying <svg> element t.stringLiteral(`octicon octicon-${key}`), t.arrowFunctionExpression([], t.blockStatement([t.returnStatement(svgData)])) ]), 'leading', '#__PURE__' )
211 212 213 214 215 216 217 218 219 220
} else if (methodName === 'componentWillUnmount') { // 处理componentWillUnmount this.collectHooks('useEffect') const expression = t.expressionStatement( t.callExpression(t.identifier('useEffect'), [ t.arrowFunctionExpression( [], t.blockStatement([t.returnStatement(this.createArrowFn(node))]) ), t.arrayExpression([])
+ 5 other calls in file
GitHub: groupon/swagql

150 151 152 153 154 155 156 157 158 159
t.objectExpression([ t.objectProperty(t.identifier('name'), t.stringLiteral(graphqlName)), t.objectProperty( t.identifier('fields'), // arrow expression to deal with recursion t.arrowFunctionExpression([], t.objectExpression(fields)) ), ]), ]) ),
+ 3 other calls in file
99 100 101 102 103 104 105 106 107 108
elseIfBindings.forEach((binding) => { const { node, index } = binding; removeAttrASTByIndex(node, index); }); const callee = t.arrowFunctionExpression([], t.blockStatement([ t.ifStatement( ifAttr.value.expression, t.returnStatement(ifNode), getAlternteAST(elseIfBindings, elseBinding)
+ 2 other calls in file
78 79 80 81 82 83 84 85 86 87
BlockStatement(p) { blockStatement = p.node }, }) const arrowFunctionExpression = t.arrowFunctionExpression( [], blockStatement, ) const callExpression = t.callExpression(arrowFunctionExpression, [])
GitHub: betocantu93/glimmer.js

53 54 55 56 57 58 59 60 61
throw new Error( `createTemplate() must receive an object literal with all of the imported values for the template as its scope parameter, received: ${scopePath.type}` ); } scope = t.arrowFunctionExpression([], scopePath.node); } else { scope = t.arrowFunctionExpression([], t.objectExpression([])); }
+ 5 other calls in file
GitHub: suchipi/tofu

148 149 150 151 152 153 154 155 156 157
if (t.isNullLiteral(node) && key == '(') { this.updateCode({ ast: produce(ast, ast => { getNodeFromPath(ast, path.slice(0, -1))[ path[path.length - 1] ] = t.arrowFunctionExpression([], t.nullLiteral()); }) }); this.moveCursor(null); event.preventDefault();
+ 3 other calls in file
78 79 80 81 82 83 84 85 86 87
}); return [ t.expressionStatement( t.callExpression(builder.buildMemberExpression(t.thisExpression(), t.identifier('setState')), [ t.arrowFunctionExpression([prevStateVar], t.blockStatement([...statements, t.returnStatement(result)])) ]) ) ]; }
+ 3 other calls in file
247 248 249 250 251 252 253 254 255 256
let arrowFn; if (node.value && node.value.type === 'ArrowFunctionExpression') { arrowFn = node.value; } else { arrowFn = t.arrowFunctionExpression([], body); } return arrowFn; });
145 146 147 148 149 150 151 152 153 154
false, false ), [ node, types.arrowFunctionExpression( [], useGestureHandlerExpression( !!config.useGestureHandler, types.identifier(component)
105 106 107 108 109 110 111 112 113 114
true ) ) } }) exArray.push(t.objectProperty(t.identifier('render'), t.arrowFunctionExpression([ t.identifier('_'), t.identifier('record'), ], t.BlockStatement([ t.returnStatement(
141 142 143 144 145 146 147 148 149 150
* value: () => {}, * } */ var body = valueNode.value let afx = t.arrowFunctionExpression([], body) valueNode.value = afx } }
GitHub: wso2/oxygen-ui
116 117 118 119 120 121 122 123 124 125
t.callExpression(t.identifier('createIconComponent'), [ // The name of the generated icon t.stringLiteral(name), // The className used on the underlying <svg> element t.stringLiteral(`oxygen-icon oxygen-icon-${key}`), t.arrowFunctionExpression([], t.blockStatement([t.returnStatement(svgData)])), ]), 'leading', '#__PURE__', ),
330 331 332 333 334 335 336 337 338 339 340 341
) ) ]) const makeAsyncT = body => btypes.arrowFunctionExpression([btypes.identifier('t')], body, true) const makeTPass = () => btypes.callExpression( btypes.memberExpression(btypes.identifier('t'), btypes.identifier('pass')),
338 339 340 341 342 343 344 345 346 347 348 349
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value"); argsList.push(valueIdent); fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name)); } return t.arrowFunctionExpression(argsList, fnBody); }); } function getBinding(thisEnvFn, key, init) {
+ 81 other calls in file
408 409 410 411 412 413 414 415 416 417
body = this.visitChildren(child); } } }); return t.arrowFunctionExpression(args, body[0]); } isTerminalNode(node) { return node.constructor.name === "TerminalNodeImpl";
160 161 162 163 164 165 166 167 168 169
// 去掉类型 params[0] = t.identifier(p0.name); } const isArrow = t.isArrowFunctionExpression(fn); const fnExp = isArrow ? t.arrowFunctionExpression(params, fn.body, fn.async) : t.functionExpression(undefined, params, fn.body, fn.generator, fn.async); // fnExp.end = fn.end; fnExp.extra = fn.extra; fnExp.generator = fn.generator;
+ 25 other calls in file
143 144 145 146 147 148 149 150 151 152
consequent.expression.isNewCallExp = true; var ifCheckStmt = babel.ifStatement(test, consequent); var retCallExp = babel.callExpression(callExpNode.callee /*tempVarID*/, callExpNode.arguments); retCallExp.isNewCallExp = true; var returnStmt = babel.returnStatement(retCallExp); var arrowFunc = babel.arrowFunctionExpression([], // params babel.blockStatement(tempVarDecls.concat([ifCheckStmt, returnStmt])), inAsyncFct); // whether or not it should be async return babel.callExpression(arrowFunc, []); } exports.buildEvalCheck = buildEvalCheck;
+ 256 other calls in file
179 180 181 182 183 184 185 186 187 188 189
NODE_EQUIV: [clonedStateExp(), types.expressionStatement(equivNodeRight)], ARGS: DUMMY_NAME }); var declare3 = types.returnStatement(tempNode); var block = types.blockStatement([declare1, declare2, declare3]); var arrowFunc = types.arrowFunctionExpression([], block); return types.callExpression(arrowFunc, []); }; var transformer = function transformer(node, type) {
@babel/types.identifier is the most popular function in @babel/types (20936 examples)