Skip to content

arrayNotIncluding

Matcher for an array that does not include a specific single element.

Matchers are applied through assertObjectMatches, where they narrow the corresponding property type.

Type information that already exists in the calling scope is incorporated.

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

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