Function assertInstance

  • Narrows an unknown value to instance of constructor type T if it is type-compatible, or raises an error otherwise.

    Type Parameters

    Parameters

    • value: unknown

      The value to test.

    • ctor: C
    • Optionalmessage: string

      The error message to use if value is not type-compatible.

    Returns asserts value is InstanceType<C>

    AssertionFailedError If the value was undefined.