How to use the identifier function from babel-types

Find comprehensive JavaScript babel-types.identifier code examples handpicked from public code repositorys.

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'),
fork icon49
star icon47
watch icon12

+ 219 other calls in file

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),
        ),
      );
    }
fork icon15
star icon76
watch icon11

+ 31 other calls in file

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)
    )
  ])
);
fork icon5
star icon49
watch icon4

+ 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) {
fork icon5
star icon43
watch icon10

+ 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))) {
fork icon4
star icon12
watch icon2

+ 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)
  }
}
fork icon4
star icon12
watch icon2

+ 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)]
    )
  ),
]);
fork icon3
star icon23
watch icon2

+ 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)
      ])
fork icon1
star icon9
watch icon2

+ 154 other calls in file

101
102
103
104
105
106
107
108
109
110
            t.memberExpression(
                t.memberExpression(
                    t.thisExpression(),
                    getIdentifier(state, value)
                ),
                t.identifier(value)
            )
        )
    )
);
fork icon65
star icon2
watch icon2

+ 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;
fork icon2
star icon6
watch icon3

+ 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'), [])),
]),
fork icon2
star icon5
watch icon3

+ 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
fork icon0
star icon13
watch icon3

+ 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')
fork icon3
star icon12
watch icon0

+ 33 other calls in file

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);
        }
fork icon1
star icon9
watch icon1

+ 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 = {
fork icon0
star icon5
watch icon1

+ 3 other calls in file

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 || []
    )
fork icon0
star icon4
watch icon5

+ 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
  );
fork icon0
star icon2
watch icon1

+ 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),
        ),
        [],
fork icon0
star icon1
watch icon1

+ 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),
        ),
        [],
fork icon0
star icon1
watch icon2

57
58
59
60
61
62
63
64
65
/**
 * $ReadOnlyArray<TYPE>
 */
function readOnlyArrayOfType(thing: BabelAST) {
  return t.genericTypeAnnotation(
    t.identifier('$ReadOnlyArray'),
    t.typeParameterInstantiation([thing]),
  );
}
fork icon0
star icon1
watch icon3

+ 5 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)