Function assertNotInstanceOf

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

    Type Parameters

    • A
    • T

    Parameters

    • actual: A
    • unexpectedType: (new (...args) => T)
        • new (...args): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    • Optional msg: string

    Returns asserts actual is Exclude<A, T>

    Since

    24.7.0

    Example

    import { assertNotInstanceOf } from "assert";

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