Function assertClass

  • Cast an object to a type. Check the type at runtime.

    Type Parameters

    • T extends object
    • ARGS extends any[]

    Parameters

    • item: unknown

      Check the type of this item.

    • ty: (new (...args: ARGS) => T)

      The expected type. This should be a class.

        • new (...args): T
        • Parameters

          Returns T

    • notes: string = "Assertion Failed."

      This will be included in the error message.

    Returns T

    item

    If the item is not of the correct type, throw an Error with a detailed message.