How to use the isStatement function from @babel/types

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

181
182
183
184
185
186
187
188
189
190
export const wrappingStatement = (
  wrapper: (child?) => any,
  getInitialCursor: (ast, path: string[]) => Cursor
) => ({ ast, cursor: [start] }: { ast: any; cursor: Cursor }) => {
  const [parents, path] = getFocusPath(ast, start);
  const parentStatementIndex = findLastIndex(parents, n => t.isStatement(n));
  const parentStatement = parents[parentStatementIndex];

  let basePath;
  if (parentStatement && !t.isBlockStatement(parentStatement)) {
fork icon4
star icon0
watch icon1

+ 5 other calls in file

142
143
144
145
146
147
148
149
150
151
    replacement = t.expressionStatement(replacement);
    nodePath = "expression";
  }
}

if (this.isNodeType("Expression") && t.isStatement(replacement)) {
  if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
    return this.replaceExpressionWithStatements([replacement]);
  }
}
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)