Skip to content

assertArrayNotIncludes

Assert that an array does not include a specific element, with type narrowing.

Note that this is an identity match, so an object in an array only fails the assertion by being a reference to the same object, rather than equivalent in value to another object reference.

Note that absence has no type-level witness, so this narrows an unknown value to an array and stops there.

import { assertArrayNotIncludes } from "@kensio/smartass"
const value: unknown = ["editor", "viewer"];
assertArrayNotIncludes(value, "admin");
// value is now narrowed to an array
// unknown[]

Source file: src/assert/array-not-includes/array-not-includes.assert.ts