Function assertInstanceOf

  • Wraps the JavaScript built-in "instanceof" in a type guard assertion.

    Type Parameters

    • InstanceType

    Parameters

    • instance: unknown

      The value to check.

    • classConstructor: Constructor<InstanceType>

      The constructor that the "instance" input will be checked against.

    • OptionalfailureMessage: string

      Message to include in error message if this assertion fails.

    Returns asserts instance is InstanceType