Class DestructuredTarget

java.lang.Object
com.google.javascript.jscomp.DestructuredTarget

public final class DestructuredTarget extends Object
Represents a single target inside a destructuring pattern, whether another pattern or a lhs expression.

Call inferType to do type inference on the target lazily. This class is designed so that a caller can get information about a target, use that information to do additional type inference, and finally call inferType if desired.

  • Method Details

    • getComputedProperty

      public @Nullable Node getComputedProperty()
      Returns a COMPUTED_PROP node or null
    • hasComputedProperty

      public boolean hasComputedProperty()
    • hasStringKey

      public boolean hasStringKey()
    • getStringKey

      public @Nullable Node getStringKey()
      Returns a STRING_KEY node or null
    • getDefaultValue

      public @Nullable Node getDefaultValue()
    • hasDefaultValue

      public boolean hasDefaultValue()
    • getNode

      public Node getNode()
    • createAllNonEmptyTargetsInPattern

      public static com.google.common.collect.ImmutableList<DestructuredTarget> createAllNonEmptyTargetsInPattern(JSTypeRegistry registry, JSType patternType, Node pattern)
      Returns all the targets directly in the given pattern, except for EMPTY nodes

      EMPTY nodes occur in array patterns with elisions, e.g. `[, , a] = []`

    • createAllNonEmptyTargetsInPattern

      public static com.google.common.collect.ImmutableList<DestructuredTarget> createAllNonEmptyTargetsInPattern(JSTypeRegistry registry, com.google.common.base.Supplier<JSType> patternType, Node pattern)
      Returns all the targets directly in the given pattern, except for EMPTY nodes

      EMPTY nodes occur in array patterns with elisions, e.g. `[, , a] = []`