{"id":"3d9ee01bdbad3cd3","repo":"sindresorhus/is","slug":"expected-value-which-is-non-empty-set-received","errorCode":null,"errorMessage":"Expected value which is `non-empty set`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `non-empty set`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1761,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty array', value));\n\t}\n}\n\nexport function assertNonEmptyMap<Key = unknown, Value = unknown>(value: unknown, message?: string): asserts value is Map<Key, Value> {\n\tif (!isNonEmptyMap(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty map', value));\n\t}\n}\n\nexport function assertNonEmptyObject<Key extends keyof any = string, Value = unknown>(value: unknown, message?: string): asserts value is Record<Key, Value> {\n\tif (!isNonEmptyObject(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty object', value));\n\t}\n}\n\nexport function assertNonEmptySet<T = unknown>(value: unknown, message?: string): asserts value is Set<T> {\n\tif (!isNonEmptySet(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty set', value));\n\t}\n}\n\nexport function assertNonEmptyString(value: unknown, message?: string): asserts value is string {\n\tif (!isNonEmptyString(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty string', value));\n\t}\n}\n\nexport function assertNonEmptyStringAndNotWhitespace(value: unknown, message?: string): asserts value is string {\n\tif (!isNonEmptyStringAndNotWhitespace(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-empty string and not whitespace', value));\n\t}\n}\n\nexport function assertNonNegativeInteger(value: unknown, message?: string): asserts value is number {\n\tif (!isNonNegativeInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('non-negative integer', value));","sourceCodeStart":1743,"sourceCodeEnd":1779,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1743-L1779","documentation":"Thrown by `assertNonEmptySet()` (source/index.ts:1759) when the value is not a `Set` instance with `size > 0`. An empty Set, an array, or a WeakSet all fail; the TypeError message includes the detected type of what was actually received.","triggerScenarios":"Calling `assert.nonEmptySet(value)` with `new Set()` (empty), an array `[1, 2]`, a WeakSet, or a deserialized value (JSON has no Set representation).","commonSituations":"Passing an array where a Set is required; Sets emptied by a `.clear()` or never populated due to a logic branch being skipped; data round-tripped through JSON losing its Set-ness.","solutions":["Convert arrays with `new Set(array)` before asserting.","If empty is a valid state, use `assert.set(value)` or `is.nonEmptySet(value)` conditionally.","Trace why the Set is empty — check the code path that was supposed to `.add()` entries."],"exampleFix":"// before\nassert.nonEmptySet(allowedIds); // allowedIds is string[]\n// after\nconst allowedIdSet = new Set(allowedIds);\nassert.nonEmptySet(allowedIdSet);","handlingStrategy":"validation","validationCode":"if (value instanceof Set && value.size > 0) {\n  assert.nonEmptySet(value);\n}","typeGuard":"function isNonEmptySet<T>(v: unknown): v is Set<T> {\n  return v instanceof Set && v.size > 0;\n}","tryCatchPattern":"try {\n  assert.nonEmptySet(tags);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // set empty or not a Set — populate it or handle the empty case explicitly\n  }\n  throw error;\n}","preventionTips":["Check set.size > 0 before asserting, since new Set([]) and deduplication can silently yield empty sets","Use is.nonEmptySet(value) when an empty set is a valid state you should branch on","Remember arrays are not Sets — convert with new Set(array) first if needed"],"tags":["assertion","type-check","set","typescript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}