How to use the isBlockStatement function from babel-types

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

85
86
87
88
89
90
91
92
93
94
function hasBinding(node, name) {
  if (Array.isArray(node)) {
    return node.some(ancestor => hasBinding(ancestor, name));
  } else if (
    babelTypes.isProgram(node) ||
    babelTypes.isBlockStatement(node) ||
    babelTypes.isBlock(node)
  ) {
    return node.body.some(statement => hasBinding(statement, name));
  } else if (
fork icon0
star icon49
watch icon1

+ 5 other calls in file

79
80
81
82
83
84
85
86
87
88
    // 过一段时间再加回来
    // attrs.push(createAttribute('tid', utils.genKey(modules.key)));
    modules.key = null;
} 

const body = t.isBlockStatement(fn.body)
    ? fn.body.body.find(t.isReturnStatement)
    : fn.body;

if (body) {
fork icon330
star icon0
watch icon2

+ 7 other calls in file

90
91
92
93
94
95
96
97
98
path.traverse({
    ThisExpression (thisPath) {
        const parentNode = thisPath.parentPath.parentPath.parent;
        const isValid = t.isExpressionStatement(parentNode) || 
            t.isVariableDeclaration(parentNode) ||
            t.isBlockStatement(parentNode) || 
            t.isJSXElement(parentNode) || 
            t.isCallExpression(parentNode) || 
            (t.isJSXAttribute(parentNode) && !parentNode.name.name.startsWith('on'));
fork icon64
star icon411
watch icon8

93
94
95
96
97
98
99
100
101
102
function hasBinding(node, name) {
  if (Array.isArray(node)) {
    return node.some(ancestor => hasBinding(ancestor, name));
  } else if (
    types.isProgram(node) ||
    types.isBlockStatement(node) ||
    types.isBlock(node)
  ) {
    return node.body.some(statement => hasBinding(statement, name));
  } else if (
fork icon0
star icon1
watch icon2

55
56
57
58
59
60
61
62
63
64
65


function hasBinding(node, name) {
    if (Array.isArray(node)) {
        return node.some(ancestor => hasBinding(ancestor, name));
    }
    else if (types.isProgram(node) || types.isBlockStatement(node) || types.isBlock(node)) {
        return node.body.some(statement => hasBinding(statement, name));
    }
    else if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node) || types.isArrowFunctionExpression(node)) {
        return (
fork icon0
star icon2
watch icon0

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