@salesforce/ts-types
    Preparing search index...

    Function hasArray

    • Tests whether a value of type T contains a property key of type AnyArray. If so, the type of the tested value is narrowed to reflect the existence of that key for convenient access in the same scope. Returns false if the property key does not exist on the object or the value stored by that key is not of type AnyArray.

      // type of obj -> unknown
      if (hasNumber(obj, 'offset')) {
      // type of obj -> { offset: number }
      if (hasNumber(obj, 'page') && hasArray(obj, 'items')) {
      // type of obj -> { offset: number } & { page: number } & { items: AnyArray }
      }
      }

      Type Parameters

      • T
      • K extends string

      Parameters

      Returns value is T & object & View<K, AnyArray>