src/com/google/javascript/jscomp/Es6RewriteClassExtendsExpressions.java
/**
   * Find common cases where we can safely decompose class extends expressions which are not
   * qualified names. Enables transpilation of complex extends expressions.
   *
   * <p>We can only decompose the expression in a limited set of cases to avoid changing evaluation
   * order of side-effect causing statements.
   */
Find common cases where we can safely decompose class extends expressions which are not
qualified names. Enables transpilation of complex extends expressions.

We can only decompose the expression in a limited set of cases to avoid changing evaluation
order of side-effect causing statements.
Find common cases where we can safely decompose class extends expressions which are not qualified names . Enables transpilation of complex extends expressions . We can only decompose the expression in a limited set of cases to avoid changing evaluation order of side - effect causing statements .
private boolean canDecomposeSimply(Node classNode) {
    Node enclosingStatement = checkNotNull(NodeUtil.getEnclosingStatement(classNode), classNode);
    if (enclosingStatement == classNode) {
      return true;
    } else {
      Node classNodeParent = classNode.getParent();
      if (NodeUtil.isNameDeclaration(enclosingStatement)
          && classNodeParent.isName()
          && classNodeParent.isFirstChildOf(enclosingStatement)) {
        return true;
      } else if (enclosingStatement.isExprResult()
          && classNodeParent.isOnlyChildOf(enclosingStatement)
          && classNodeParent.isAssign()
          && classNode.isSecondChildOf(classNodeParent)) {
        Node lhsNode = classNodeParent.getFirstChild();
        return !NodeUtil.mayHaveSideEffects(lhsNode);
      } else {
        return false;
      }
    }
  }
private boolean canDecomposeSimply ( Node classNode ) { Node enclosingStatement = checkNotNull ( NodeUtil . getEnclosingStatement ( classNode ) , classNode ) ; if ( enclosingStatement == classNode ) { return true ; } else { Node classNodeParent = classNode . getParent ( ) ; if ( NodeUtil . isNameDeclaration ( enclosingStatement ) && classNodeParent . isName ( ) && classNodeParent . isFirstChildOf ( enclosingStatement ) ) { return true ; } else if ( enclosingStatement . isExprResult ( ) && classNodeParent . isOnlyChildOf ( enclosingStatement ) && classNodeParent . isAssign ( ) && classNode . isSecondChildOf ( classNodeParent ) ) { Node lhsNode = classNodeParent . getFirstChild ( ) ; return ! NodeUtil . mayHaveSideEffects ( lhsNode ) ; } else { return false ; } } }
Find common cases where we can safely decompose class extends expressions which are not
 qualified names.
Find common cases where we can safely decompose class extends expressions which are not qualified names .
// `class Foo extends some_expression {}` // can always be converted to // ``` // const tmpvar = some_expression; // class Foo extends tmpvar {} // ``` // `const Foo = class extends some_expression {}, maybe_other_var;` // can always be converted to // ``` // const tmpvar = some_expression; // const Foo = class extends tmpvar {}, maybe_other_var; // ``` // `lhs = class extends some_expression {};` // We can extract a temporary variable for some_expression as long as lhs expression // has no side effects.