{"id":"57dbe849b047801a","repo":"sindresorhus/is","slug":"expected-value-which-is-empty-map-received-valu","errorCode":null,"errorMessage":"Expected value which is `empty map`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `empty map`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1562,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('Date', value));\n\t}\n}\n\nexport function assertDirectInstanceOf<T>(instance: unknown, class_: Class<T>, message?: string): asserts instance is T {\n\tif (!isDirectInstanceOf(instance, class_)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('T', instance));\n\t}\n}\n\nexport function assertEmptyArray(value: unknown, message?: string): asserts value is never[] {\n\tif (!isEmptyArray(value)) {\n\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));","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1544-L1580","documentation":"Thrown by `assertEmptyMap` (source/index.ts:1560) in the sindresorhus `@sindresorhus/is` library when the given value is not a Map with size 0. The message interpolates `is(value)` to report the actual detected type. Assert functions in this library throw a TypeError instead of returning false, giving TypeScript an `asserts value is Map<never, never>` narrowing.","triggerScenarios":"Calling `assert.emptyMap(value)` / `assertEmptyMap(value)` with a non-Map value (object, array, null), or with a Map that has one or more entries.","commonSituations":"Validating that a cache/registry starts empty before initialization; test setup asserting a Map was cleared; passing a plain object `{}` where a real `Map` instance is expected; a Map unexpectedly retaining entries because `clear()` was never called or state leaked between tests.","solutions":["Ensure the value is an actual `Map` instance, not a plain object — construct with `new Map()`","If the Map may legitimately have entries, use `assert.map(value)` (non-empty allowed) or `is.emptyMap(value)` as a boolean check instead of asserting","Clear the Map (`map.clear()`) before the assertion if empty state is required","Pass a custom `message` argument to make the failure context clearer"],"exampleFix":"// before\nassert.emptyMap({}); // plain object, throws\n// after\nassert.emptyMap(new Map());","handlingStrategy":"type-guard","validationCode":"if (is.map(value) && value.size === 0) {\n  assert.emptyMap(value); // safe\n}","typeGuard":"function isEmptyMap(value: unknown): value is Map<unknown, unknown> {\n  return value instanceof Map && value.size === 0;\n}","tryCatchPattern":"try {\n  assert.emptyMap(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // value was not an empty Map — inspect is(value) in the message\n  } else throw error;\n}","preventionTips":["Check is.map(value) first, then value.size === 0, before calling assert.emptyMap","Remember non-Map values (objects, arrays) fail this assertion even if 'empty'","Clear a Map with map.clear() rather than reassigning to {} which changes the type"],"tags":["type-assertion","runtime-validation","map","typescript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}