{"id":"f1296587dd50183c","repo":"sindresorhus/is","slug":"expected-value-which-is-falsy-received-value-of","errorCode":null,"errorMessage":"Expected value which is `falsy`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `falsy`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"warning","filePath":"source/index.ts","lineNumber":1610,"sourceCode":"\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));\n\t}\n}\n\nexport function assertEvenInteger(value: number, message?: string): asserts value is number {\n\tif (!isEvenInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('even integer', value));\n\t}\n}\n\nexport function assertFalsy(value: unknown, message?: string): asserts value is Falsy {\n\tif (!isFalsy(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('falsy', value));\n\t}\n}\n\nexport function assertFiniteNumber(value: unknown, message?: string): asserts value is number {\n\tif (!isFiniteNumber(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('finite number', value));\n\t}\n}\n\nexport function assertFloat32Array(value: unknown, message?: string): asserts value is Float32Array {\n\tif (!isFloat32Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Float32Array', value));\n\t}\n}\n\nexport function assertFloat64Array(value: unknown, message?: string): asserts value is Float64Array {\n\tif (!isFloat64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Float64Array', value));","sourceCodeStart":1592,"sourceCodeEnd":1628,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1592-L1628","documentation":"Thrown by `assertFalsy` (source/index.ts:1608) when the value is truthy. It narrows to the `Falsy` type (`false | 0 | '' | null | undefined | 0n | NaN`) on success; any truthy value — non-empty string, non-zero number, any object or array (even empty ones) — throws a TypeError with the detected type.","triggerScenarios":"Calling `assert.falsy(value)` with any truthy value, notably `[]`, `{}`, `'false'`, `'0'`, or `new Boolean(false)`, all of which are truthy in JavaScript despite looking empty or false.","commonSituations":"Asserting a flag or cached value is unset; env vars like `DEBUG='false'` being truthy because they're non-empty strings; empty arrays/objects passed where the author expected them to count as falsy; test assertions that a cleanup left a field cleared.","solutions":["Check for JavaScript truthiness gotchas: `[]`, `{}`, and `'false'` are all truthy — compare explicitly if that's what you mean","Parse string flags before asserting: `value === 'true'` rather than relying on truthiness","If you need 'no meaningful value', assert the specific case (`assert.undefined`, `assert.null`, `assert.emptyArray`) instead of falsy"],"exampleFix":"// before\nassert.falsy(process.env.DEBUG); // 'false' is truthy, throws\n// after\nassert.falsy(process.env.DEBUG === 'true' ? true : undefined);\n// or better: const debug = process.env.DEBUG === 'true'; assert.falsy(debug || undefined)","handlingStrategy":"type-guard","validationCode":"if (!value) {\n  assert.falsy(value);\n}","typeGuard":"function isFalsy(value: unknown): value is false | 0 | '' | null | undefined {\n  return !value;\n}","tryCatchPattern":"try {\n  assert.falsy(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // value was truthy — remember empty arrays/objects and the string '0' are truthy\n  } else throw error;\n}","preventionTips":["Memorize the falsy set: false, 0, -0, 0n, '', null, undefined, NaN — everything else is truthy","Empty arrays [] and empty objects {} are truthy; use the empty* assertions for those","Prefer explicit checks (value === null, value === 0) over falsy when only one falsy case is valid"],"tags":["type-assertion","runtime-validation","truthiness","javascript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}