{"id":"f0e2f13a2a63b977","repo":"sindresorhus/is","slug":"expected-value-which-is-empty-string-received-v","errorCode":null,"errorMessage":"Expected value which is `empty string`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `empty string`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1580,"sourceCode":"\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));\n\t}\n}\n\nexport function assertError(value: unknown, message?: string): asserts value is Error {\n\tif (!isError(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Error', value));","sourceCodeStart":1562,"sourceCodeEnd":1598,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1562-L1598","documentation":"Thrown by `assertEmptyString` (source/index.ts:1578) when the value is not exactly the empty string `''`. On success TypeScript narrows the value to the literal type `''`; any non-string, or a string with length > 0 (including whitespace-only strings), throws a TypeError reporting the detected type.","triggerScenarios":"Calling `assert.emptyString(value)` with a non-empty string, a whitespace-only string like `' '`, or a non-string value such as null or undefined.","commonSituations":"Asserting a form field or buffer was reset; whitespace-only input like `' '` unexpectedly failing because it isn't strictly empty; `undefined`/`null` from an unset env var or missing object property being passed where `''` was expected.","solutions":["If whitespace-only strings should also pass, use `assert.emptyStringOrWhitespace(value)` instead","Trim or reset the string to `''` before the assertion if empty is the required state","Guard against null/undefined upstream — the assertion requires an actual string","If the goal is the opposite (require content), use `assert.nonEmptyString(value)`"],"exampleFix":"// before\nassert.emptyString(' '); // whitespace, throws\n// after\nassert.emptyStringOrWhitespace(' ');","handlingStrategy":"type-guard","validationCode":"if (typeof value === 'string' && value.length === 0) {\n  assert.emptyString(value);\n}","typeGuard":"function isEmptyString(value: unknown): value is '' {\n  return typeof value === 'string' && value.length === 0;\n}","tryCatchPattern":"try {\n  assert.emptyString(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // value is non-string or a non-empty string (whitespace counts as non-empty here)\n  } else throw error;\n}","preventionTips":["Remember ' ' (whitespace) is NOT an empty string for this check — use emptyStringOrWhitespace for that","null and undefined are not empty strings; normalize with value ?? '' if that's the intent","Prefer value === '' as a direct check when you don't need the assertion's throw behavior"],"tags":["type-assertion","runtime-validation","string","typescript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}