How to use the isVariableDeclarator function from babel-types

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

195
196
197
198
199
200
201
202
203

// var Foo = { bar: ... }
if (n.isIdentifier(path) &&
    n.isObjectProperty(path.parentPath) &&
    n.isObjectExpression(path.parentPath.parentPath) &&
    n.isVariableDeclarator(path.parentPath.parentPath.parentPath)) {
  identifiers = [path.parentPath.parentPath.parentPath.node.id.name];
  inferMembershipFromIdentifiers(comment, identifiers);
}
fork icon510
star icon0
watch icon2

+ 3 other calls in file

87
88
89
90
91
92
93
94
95
96
//       return new Vue(App)
//    }
// })
VariableDeclaration: function (path) {
  if (path.node.declarations &&
    t.isVariableDeclarator(path.node.declarations[0]) &&
    t.isNewExpression(path.node.declarations[0].init) &&
    t.isIdentifier(path.node.declarations[0].init.callee, { name: 'Vue' })
  ) {
    const fnExpression = t.functionExpression(
fork icon49
star icon47
watch icon12

+ 43 other calls in file

36
37
38
39
40
41
42
43
44
45
const comments = (path.node.leadingComments || []).filter(isJSDocComment);

if (!comments.length) {
  // If this is the first declarator we check for comments on the VariableDeclaration.
  if (
    t.isVariableDeclarator(path) &&
    path.parentPath.get('declarations')[0] === path
  ) {
    return getComments(data, path.parentPath);
  }
fork icon509
star icon3
watch icon3

101
102
103
104
105
106
107
108
109
  return ast.program.body.find(
    stmt =>
      types.isVariableDeclaration(stmt) &&
      stmt.kind === kind &&
      stmt.declarations.length === 1 &&
      types.isVariableDeclarator(stmt.declarations[0]) &&
      stmt.declarations[0].id.name === name
  );
}
fork icon0
star icon2
watch icon1

+ 7 other calls in file

138
139
140
141
142
143
144
145
146
147

  return parent.node.source.value === name;

  // e.g. var fs = require('fs');
} else if (
  t.isVariableDeclarator(bindingNode) ||
  t.isAssignmentExpression(bindingNode)
) {
  let left = bindingNode.id || bindingNode.left;
  let right = bindingNode.init || bindingNode.right;
fork icon0
star icon1
watch icon2

Other functions in babel-types

Sorted by popularity

function icon

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