assertNotInstanceOf

import { assertNotInstanceOf } from "jsr:@ende/assert";

function

function assertNotInstanceOf<A, T>(actual: A, unexpectedType: new (...args: any[]) => T, msg?: string): asserts actual is Exclude<A, T>

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

actual: A

The object to check.

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

The class constructor to check against.

msg?: string

The optional message to display if the assertion fails.

Example: Usage

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

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

Source