Function assertNotInstanceOf

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

    Type Parameters

    • A

      The type of the object to check.

    • T

      The type of the class to check against.

    Parameters

    • actual: A

      The object to check.

    • unexpectedType: (new (...args: any[]) => T)

      The class constructor to check against.

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

          • Rest...args: any[]

          Returns T

    • Optionalmsg: string

      The optional message to display if the assertion fails.

    Returns asserts actual is Exclude<A, T>

    import { assertNotInstanceOf } from "@std/assert";

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