How to use the identifier function from babel-types
Find comprehensive JavaScript babel-types.identifier code examples handpicked from public code repositorys.
GitHub: mpvue/mpvue-loader
112 113 114 115 116 117 118 119 120 121
[ t.objectProperty( t.identifier('mpType'), t.MemberExpression( t.identifier(path.node.declarations[0].init.arguments[0].name), t.identifier('mpType') ) ), t.objectProperty( t.identifier('init'),
49
47
12
+ 219 other calls in file
GitHub: alipay/goldfish
8 9 10 11 12 13 14 15 16 17
function getImport(path) { return path.node.specifiers.reduce((result, specifier) => { if (specifier.imported) { result.push( babelTypes.importSpecifier( babelTypes.identifier(specifier.local.name), babelTypes.identifier(specifier.imported.name), ), ); }
15
76
11
+ 31 other calls in file
GitHub: wx-chevalier/ueact
147 148 149 150 151 152 153 154 155 156
objArr = convertObjectToAstExpression(obj); } astPath.replaceWith( t.variableDeclaration('const', [ t.variableDeclarator( t.identifier(defaultSpecifier), t.objectExpression(objArr) ) ]) );
5
49
4
+ 3 other calls in file
139 140 141 142 143 144 145 146 147 148
return node; }, ast_buffer: function(ast) { return [t.expressionStatement( t.assignmentExpression('=', t.identifier('pug_html'), t.binaryExpression('+', t.identifier('pug_html'), ast) ))]; }, ast_with: function(ast) {
5
43
10
+ 114 other calls in file
194 195 196 197 198 199 200 201 202 203
const queryValue = queryInfo && queryInfo.value const paramsValueList = paramsValue && paramsValue.properties ? paramsValue.properties : [] const queryValueList = queryValue && queryValue.properties ? queryValue.properties : [] const paramsItems = [].concat(paramsValueList, queryValueList).map(item => ({ key: item.key, value: item.value })) const url = types.identifier('url') const routeName = nameInfo.value.value let expressions, quasis if (paramsItems.some(item => types.isCallExpression(item.value) || types.isMemberExpression(item.value))) {
4
12
2
+ 259 other calls in file
337 338 339 340 341 342 343 344 345 346
// 把export default 替换成 Page 或者 Component const { metadata } = path.hub.file const { declaration } = path.node const newArguments = [declaration] const name = metadata.isComponent ? 'Component' : 'Page' const newCallee = types.identifier(name) const newCallExpression = types.CallExpression(newCallee, newArguments) path.replaceWith(newCallExpression) } }
4
12
2
+ 131 other calls in file
328 329 330 331 332 333 334 335 336 337
//id就是identifier //此处的init必须是一个Expression types.identifier(varName), //t.callExpression(callee, arguments) types.callExpression( types.identifier('require'), [types.stringLiteral(moduleName)] ) ), ]);
3
23
2
+ 11 other calls in file
38 39 40 41 42 43 44 45 46 47
}; const NullableTypeAnnotation = (node, initialPath) => t.objectExpression([ t.objectProperty( t.identifier('anyOf'), t.arrayExpression([ NullLiteralTypeAnnotation(), convert(node.typeAnnotation, initialPath) ])
1
9
2
+ 154 other calls in file
GitHub: KieSun/vue-to-react
101 102 103 104 105 106 107 108 109 110
t.memberExpression( t.memberExpression( t.thisExpression(), getIdentifier(state, value) ), t.identifier(value) ) ) ) );
65
2
2
+ 59 other calls in file
78 79 80 81 82 83 84 85 86
let declaration; switch (type) { case 'NAMESPACE': declaration = namespaceTemplate({ LOCAL: t.identifier(local), MODULE_NAME: t.stringLiteral(moduleName) }); break;
2
6
3
+ 35 other calls in file
21 22 23 24 25 26 27 28 29 30
t.blockStatement([ t.expressionStatement( t.assignmentExpression( '=', t.identifier('emptyContinuationAux'), t.identifier('emptyContinuation'), ), ), t.expressionStatement(t.callExpression(t.identifier('emptyContinuation'), [])), ]),
2
5
3
+ 31 other calls in file
35 36 37 38 39 40 41 42 43 44
const staticContent = contentsMap.get(sourceName) // change the node from a css import to static content const newAst = buildStaticCssReference({ ORIGIN: t.stringLiteral(sourceName), IMPORT_NAME: t.identifier(importName), SOURCE: t.objectExpression(staticContent), }) // replace the origina impot with the static css map
0
13
3
+ 3 other calls in file
226 227 228 229 230 231 232 233 234 235
let newPoperty if (property.name === 'replace') { newPoperty = types.identifier('redirectTo') } if (property.name === 'push') { newPoperty = types.identifier('navigateTo') } const newArguments = [types.objectExpression([objectProperty])] const newObject = types.identifier('wx')
3
12
0
+ 33 other calls in file
GitHub: Zenquan/babel-plugin-import
189 190 191 192 193 194 195 196 197 198
let ClassPlugin = { visitor: { ClassDeclaration(path){ let {node} = path; let className = node.id.name; className = t.identifier(className); //console.log(className); let funs = t.functionDeclaration(className, [], t.blockStatement([]), false, false); path.replaceWith(funs); }
1
9
1
+ 65 other calls in file
10 11 12 13 14 15 16 17 18 19 20 21
}; var formCSSXSheetDefinition = function (selectorNode, options) { return t.callExpression( t.identifier('cssx'), selectorNode ? [ t.identifier(selectorNode.value) ] : [] ); }; module.exports = {
0
5
1
+ 3 other calls in file
GitHub: sorrycc/taro
168 169 170 171 172 173 174 175 176 177
node.superClass.object.name = taroImportDefaultName if (node.id === null) { const renameComponentClassName = '_TaroComponentClass' astPath.replaceWith( t.classExpression( t.identifier(renameComponentClassName), node.superClass, node.body, node.decorators || [] )
0
4
5
+ 7 other calls in file
21 22 23 24 25 26 27 28 29 30
}); } function shorthandProperty(name) { return types.objectProperty( types.identifier(name), types.identifier(name), false, true );
0
2
1
+ 31 other calls in file
182 183 184 185 186 187 188 189 190 191
const RelayCodeGenVisitor = { leave: { Root(node) { return t.exportNamedDeclaration( t.typeAlias( t.identifier(node.name), null, selectionsToBabel(node.selections), ), [],
0
1
1
+ 5 other calls in file
209 210 211 212 213 214 215 216 217 218
const RelayCodeGenVisitor = { leave: { Root(node) { return t.exportNamedDeclaration( t.typeAlias( t.identifier(`${node.name}Response`), null, selectionsToBabel(node.selections), ), [],
0
1
2
57 58 59 60 61 62 63 64 65
/** * $ReadOnlyArray<TYPE> */ function readOnlyArrayOfType(thing: BabelAST) { return t.genericTypeAnnotation( t.identifier('$ReadOnlyArray'), t.typeParameterInstantiation([thing]), ); }
0
1
3
+ 5 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)