{"id":"f20afe1cae45520e","repo":"sindresorhus/is","slug":"expected-value-which-is-empty-set-received-valu","errorCode":null,"errorMessage":"Expected value which is `empty set`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `empty set`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1574,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('empty array', value));\n\t}\n}\n\nexport function assertEmptyMap(value: unknown, message?: string): asserts value is Map<never, never> {\n\tif (!isEmptyMap(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('empty map', value));\n\t}\n}\n\nexport function assertEmptyObject<Key extends keyof any = string>(value: unknown, message?: string): asserts value is Record<Key, never> {\n\tif (!isEmptyObject(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('empty object', value));\n\t}\n}\n\nexport function assertEmptySet(value: unknown, message?: string): asserts value is Set<never> {\n\tif (!isEmptySet(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('empty set', value));\n\t}\n}\n\nexport function assertEmptyString(value: unknown, message?: string): asserts value is '' {\n\tif (!isEmptyString(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('empty string', value));\n\t}\n}\n\nexport function assertEmptyStringOrWhitespace(value: unknown, message?: string): asserts value is '' | Whitespace {\n\tif (!isEmptyStringOrWhitespace(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('empty string or whitespace', value));\n\t}\n}\n\nexport function assertEnumCase<T = unknown>(value: unknown, targetEnum: T, message?: string): asserts value is T[keyof T] {\n\tif (!isEnumCase(value, targetEnum)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('EnumCase', value));","sourceCodeStart":1556,"sourceCodeEnd":1592,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1556-L1592","documentation":"Thrown by `assertEmptySet` (source/index.ts:1572) when the value is not a Set instance with size 0. The assertion narrows to `Set<never>` on success and throws a TypeError containing the actual type from `is(value)` on failure.","triggerScenarios":"Calling `assert.emptySet(value)` with a non-Set (array, object, Map) or with a Set containing one or more elements.","commonSituations":"Test teardown verifying a subscriber/listener Set was drained; passing an array `[]` where a `Set` is required; a Set retaining members because deduplicated cleanup logic missed items or `clear()` wasn't called.","solutions":["Pass a genuine `Set` instance (`new Set()`), not an array or other iterable","If members are allowed, switch to `assert.set(value)` or check `is.emptySet(value)` as a boolean","Call `set.clear()` before asserting when the invariant is that processing has emptied it"],"exampleFix":"// before\nassert.emptySet([]); // array, throws\n// after\nassert.emptySet(new Set());","handlingStrategy":"type-guard","validationCode":"if (is.set(value) && value.size === 0) {\n  assert.emptySet(value);\n}","typeGuard":"function isEmptySet(value: unknown): value is Set<unknown> {\n  return value instanceof Set && value.size === 0;\n}","tryCatchPattern":"try {\n  assert.emptySet(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // value is not a Set, or the Set has members\n  } else throw error;\n}","preventionTips":["Verify the value is actually a Set (not an array or Map) before asserting emptiness","Use set.clear() to empty a Set in place; reassigning to [] changes its type","Prefer the boolean form is.emptySet(value) when a non-empty Set is a normal, expected case"],"tags":["type-assertion","runtime-validation","set","typescript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}