• Make an assertion that obj is an instance of type. If not then throw.

    Type Parameters

    Parameters

    • actual: unknown
    • expectedType: T
    • Optional msg: string

    Returns asserts actual is GetConstructorType<T>

    Since

    24.7.0

    Example

    import { assertInstanceOf } from "assert";

    assertInstanceOf(new Date(), Date); // Doesn't throw
    assertInstanceOf(new Date(), Number); // Throws