⚠️ Internal: This API is not publically exported by the package.
  • Checks if an item is in an array. Asserts that item is of the same type as union of array items. Useful to prevent needing to assert an unknown value before checking if it is in a strongly typed array.

    Type Parameters

    • T extends unknown[] | readonly unknown[]

    Parameters

    • item: unknown
    • array: T

    Returns item is T[number]

    Example

    `isItemInArrayGuard(someNumber, [1, 2, 3])` INSTEAD OF `[1, 2, 3].includes(someNumber as [1, 2, 3][number])`