How to use the isClassMethod function from babel-types

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

2
3
4
5
6
7
8
9
10
11
const ANONYMOUS_FUNCTION = 'anonymous function';

const isNodeTypeAFunction = n =>
        t.isFunctionDeclaration(n) ||
        t.isArrowFunctionExpression(n) ||
        t.isClassMethod(n) ||
        t.isFunctionExpression(n);

// What to do with declareFunction type?
const isPathTypeAFunction = p =>
fork icon2
star icon60
watch icon3

118
119
120
121
122
123
124
125
126
127
  return ast.program.body.find(types.isExportDefaultDeclaration);
}

function findClassMethodDeclaration(classDeclaration, method) {
  return classDeclaration.body.body.find(
    stmt => types.isClassMethod(stmt) && stmt.key.name === method
  );
}

function findReturnStatement(body) {
fork icon0
star icon2
watch icon1

+ 7 other calls in file

26
27
28
29
30
31
32
33
34
35
// If this is an ES6 class with a constructor method, infer
// parameters from that constructor method.
if (t.isClassDeclaration(path)) {
  let constructor = path.node.body.body.find(item => {
    // https://github.com/babel/babylon/blob/master/ast/spec.md#classbody
    return t.isClassMethod(item) && item.kind === 'constructor';
  });
  if (constructor) {
    return inferAndCombineParams(constructor.params, comment);
  }
fork icon509
star icon0
watch icon2

4
5
6
7
8
9
10
11
12
13
function isModuleNode(node) {
  return types.isModuleDeclaration(node);
}

function isClassMethodBody(block) {
  return types.isClassMethod(block.container);
}

function isModule(block) {
  return block.node.body.some(isModuleNode);
fork icon0
star icon0
watch icon1

+ 3 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)