How to use the isClassDeclaration function from @babel/types

Find comprehensive JavaScript @babel/types.isClassDeclaration code examples handpicked from public code repositorys.

86
87
88
89
90
91
92
93
94
95
    } else if (t.isIdentifier(path.parent.callee)) {
        const idx = path.parent.arguments.indexOf(path.node)
        funcName = path.parent.callee.name + '(callback-' + idx + ')'
    }
} else if (t.isClassMethod(path.node)) {
    const parent = path.findParent(p => t.isClassDeclaration(p) || t.isClassExpression(p))

    if (t.isIdentifier(parent.node.id)) {
        if (t.isIdentifier(path.node.key)) {
            funcName = parent.node.id.name + '.' + path.node.key.name
fork icon5
star icon27
watch icon1

+ 21 other calls in file

22
23
24
25
26
27
28
29
30
31
}

// If this is an ES6 class with a constructor method, infer
// parameters from that constructor method.
if (
  t.isClassDeclaration(path) &&
  !(comment.constructorComment && comment.constructorComment.hideconstructor)
) {
  const constructor = path.node.body.body.find(item => {
    // https://github.com/babel/babylon/blob/master/ast/spec.md#classbody
fork icon510
star icon0
watch icon5

+ 7 other calls in file

144
145
146
147
148
149
150
151
152
153

if (t.isIdentifier(declaration)) {
  local = declaration.name;
} else if (
  t.isFunctionDeclaration(declaration) ||
  t.isClassDeclaration(declaration)
) {
  if (declaration.id) {
    local = declaration.id.name;
  } else {
fork icon6
star icon34
watch icon3

+ 19 other calls in file

586
587
588
589
590
591
592
593
594
595
      outputASTs.push(resultsAST);
    }
  }
}
if (types.isFunctionDeclaration(declaration) ||
  types.isClassDeclaration(declaration)) {
  const identifier = declaration.id;
  const resultsAST = astCodeToAddToModuleExports(identifier, identifier.name);
  copyLocation(declaration, resultsAST);
  outputASTs.push(resultsAST);
fork icon0
star icon0
watch icon0

+ 21 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 (20936 examples)