Skip to content

setNotIncluding

Matcher for a Set that does not hold a specific member.

Membership uses the Set’s own has(), which is an identity match for objects, so an equal-valued object held under another reference passes the check.

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

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

import { assertObjectMatches, setNotIncluding } from "@kensio/smartass";
const value: unknown = {
tags: new Set(["draft", "featured"]),
};
assertObjectMatches(value, {
tags: setNotIncluding("archived"),
});
// value is now narrowed to an object with a Set of tags
// {
// tags: ReadonlySet<unknown>;
// }

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