How to use the isUpdateExpression function from @babel/types

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

138
139
140
141
142
143
144
145
146
147
const controlFlowDeflatteningVisitor = {
  SwitchStatement(path){
    // First, we check to make sure we are at a good SwitchStatement node
    if(types.isMemberExpression(path.node.discriminant) &&
        types.isIdentifier(path.node.discriminant.object) &&
        types.isUpdateExpression(path.node.discriminant.property) &&
        path.node.discriminant.property.operator === "++" &&
        path.node.discriminant.property.prefix === false){
          // After we've made sure we got to the right node, we'll
          // make a variable that will hold the cases in their order of execution
fork icon2
star icon16
watch icon1

+ 3 other calls in file

125
126
127
128
129
130
131
132
133
134
path.get('object').replaceWithSourceString('this.data')

if (
  (t.isAssignmentExpression(path.parentPath) &&
    path.parentPath.get('left') === path) ||
  t.isUpdateExpression(path.parentPath)
) {
  // findParent
  const expressionStatement = path.findParent(parent =>
    parent.isExpressionStatement(),
fork icon2
star icon16
watch icon1

38
39
40
41
42
43
44
45
46
47
const getNewNode = (literal, reference) => {
  let newNode;
  if (t.isStringLiteral(literal)) {
    newNode = t.stringLiteral(literal.value)
  } else if (t.isNumericLiteral(literal)) {
    if (reference && t.isUpdateExpression(reference.parent)) {
      // Handle the fact that we don't want to replace in this case
      // c5 && a5[g5] ? ++0 : t5 += " unsupported"
      newNode = null
    } else {
fork icon1
star icon6
watch icon7

Other functions in @babel/types

Sorted by popularity

function icon

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