How to use the isExpression function from @babel/types

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

158
159
160
161
162
163
164
165
166
167
  return;
}

{
  const isExpressionOrBlock =
    t.isExpression(node) &&
    !t.isStringLiteral(node) &&
    !t.isTemplateLiteral(node);

  if (isExpressionOrBlock && ['(', '[', '{'].includes(key)) {
fork icon4
star icon0
watch icon1

+ 3 other calls in file

59
60
61
62
63
64
65
66
67
68
  return isRight ? nextStart : start;
}

if (
  t.isExpression(node) &&
  t.isExpression(getNode(ast, nextStart)) &&
  !t.isArrowFunctionExpression(node)
) {
  if (
    (code[nextStart] == '(' && recursionDepth === 0) ||
fork icon4
star icon0
watch icon1

+ 27 other calls in file

68
69
70
71
72
73
74
75
76
77
78
79
  }


  if (this.isExpression()) {
    return t.isBlockStatement(replacement);
  } else if (this.isBlockStatement()) {
    return t.isExpression(replacement);
  }


  return false;
}
fork icon1
star icon0
watch icon0

88
89
90
91
92
93
94
95
96
97
98
99


  checkPath(path) {
    if (path.isIdentifier()) {
      return path.isReferencedIdentifier();
    } else {
      return t.isExpression(path.node);
    }
  }


};
fork icon0
star icon0
watch icon0

96
97
98
99
100
101
102
103
104
105
  parentPath
} = this;

if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
  return parentPath.insertAfter(nodes.map(node => {
    return t.isExpression(node) ? t.expressionStatement(node) : node;
  }));
} else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
  if (this.node) {
    let {
fork icon0
star icon0
watch icon0

135
136
137
138
139
140
141
142
143
144
  throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`");
}

let nodePath = "";

if (this.isNodeType("Statement") && t.isExpression(replacement)) {
  if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) {
    replacement = t.expressionStatement(replacement);
    nodePath = "expression";
  }
fork icon0
star icon0
watch icon0

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)