How to use the newExpression function from @babel/types
Find comprehensive JavaScript @babel/types.newExpression code examples handpicked from public code repositorys.
171 172 173 174 175 176 177 178 179 180
'body', t.expressionStatement( t.assignmentExpression( '=', t.memberExpression(t.identifier('client'), t.identifier(apiInstanceName)), t.newExpression(t.identifier(apiClassName), [ t.memberExpression(t.thisExpression(), t.identifier('request')), t.memberExpression(t.thisExpression(), t.identifier('config')), ]), ),
+ 5 other calls in file
GitHub: groupon/swagql
![groupon profile picture](/groupon.png?size=40)
40 41 42 43 44 45 46 47 48 49
return upperFirst(camelCase(typeName)); } function generateListReference(typeMap, apiType) { const ofType = typeMap.ref(apiType.items, true); return t.newExpression(typeMap.listTypeRef, [ofType]); } function generateListAST(typeMap, type) { const { graphqlName, apiType } = type;
+ 5 other calls in file
GitHub: overlookmotel/livepack
![overlookmotel profile picture](/overlookmotel.png?size=40)
21 22 23 24 25 26 27 28 29 30
module.exports = { serializeBoxedString(str, record) { const StringRecord = this.serializeValue(String), len = str.length; const node = t.newExpression( StringRecord.varNode, len > 0 ? [t.stringLiteral(stringToString.call(str))] : [] ); createDependency(record, StringRecord, node, 'callee');
+ 5 other calls in file
GitHub: overlookmotel/livepack
![overlookmotel profile picture](/overlookmotel.png?size=40)
29 30 31 32 33 34 35 36 37
}, serializeDate(date, record) { // `new Date(...)` const dateCtorRecord = this.serializeValue(Date); const node = t.newExpression(dateCtorRecord.varNode, [t.numericLiteral(dateGetTime.call(date))]); createDependency(record, dateCtorRecord, node, 'callee'); return this.wrapWithProperties(date, record, node, Date.prototype); },
+ 5 other calls in file
GitHub: ruleenginejs/ruleengine
81 82 83 84 85 86 87 88 89 90 91
function generateNewInstance(varName, className, args = []) { return t.variableDeclaration('const', [ t.variableDeclarator( t.identifier(varName), t.newExpression(t.identifier(className), args) ) ]); }
+ 57 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)