{"id":"6b330dd06c1f8242","repo":"sindresorhus/is","slug":"expected-value-which-is-symbol-received-value-o","errorCode":null,"errorMessage":"Expected value which is `symbol`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `symbol`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1902,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('Set', value));\n\t}\n}\n\nexport function assertSharedArrayBuffer(value: unknown, message?: string): asserts value is SharedArrayBuffer {\n\tif (!isSharedArrayBuffer(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('SharedArrayBuffer', value));\n\t}\n}\n\nexport function assertString(value: unknown, message?: string): asserts value is string {\n\tif (!isString(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('string', value));\n\t}\n}\n\nexport function assertSymbol(value: unknown, message?: string): asserts value is symbol {\n\tif (!isSymbol(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('symbol', value));\n\t}\n}\n\nexport function assertTruthy<T>(value: T | Falsy, message?: string): asserts value is T {\n\tif (!isTruthy(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('truthy', value));\n\t}\n}\n\nexport function assertTupleLike<T extends Array<TypeGuard<unknown>>>(value: unknown, guards: [...T], message?: string): asserts value is ResolveTypesOfTypeGuardsTuple<T> {\n\tif (!isTupleLike(value, guards)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('tuple-like', value));\n\t}\n}\n\nexport function assertTypedArray(value: unknown, message?: string): asserts value is TypedArray {\n\tif (!isTypedArray(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('TypedArray', value));","sourceCodeStart":1884,"sourceCodeEnd":1920,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1884-L1920","documentation":"Thrown by `assert.symbol()` (assertSymbol at source/index.ts:1900) when the value is not a primitive `symbol` per `typeof value === 'symbol'`. Strings that look like symbol descriptions, objects, and everything else fail. Used to guarantee a value can serve as a unique, collision-free key.","triggerScenarios":"Calling `assert.symbol(value)` with a string (e.g. `'Symbol(id)'` or a plain name where `Symbol('name')` was expected), `undefined`, or the result of serialization — symbols cannot cross JSON, structuredClone, or worker boundaries.","commonSituations":"Symbols lost across module duplication (two copies of a package each creating their own `Symbol('kind')` — use `Symbol.for()` for a shared registry); values round-tripped through JSON where symbols were silently dropped to `undefined`; confusing well-known symbol names with the symbols themselves.","solutions":["Pass an actual symbol: `Symbol('name')` or `Symbol.for('name')` instead of a string.","If the symbol must be shared across modules or realms, use the global registry `Symbol.for(key)` so all copies agree.","If the value crossed a serialization boundary, redesign to use a string key there — symbols cannot be serialized."],"exampleFix":"// before\nconst kind = 'node-kind';\nassert.symbol(kind);\n// after\nconst kind = Symbol.for('node-kind');\nassert.symbol(kind);","handlingStrategy":"type-guard","validationCode":"if (typeof value !== 'symbol') {\n  throw new TypeError(`Expected a symbol, got ${typeof value}`);\n}","typeGuard":"function isSymbol(value: unknown): value is symbol {\n  return typeof value === 'symbol';\n}","tryCatchPattern":"try {\n  assert.symbol(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // a string key or Symbol description was passed instead of the Symbol itself\n  }\n  throw error;\n}","preventionTips":["Pass the Symbol value itself, not its description string or .toString() output","Symbols don't survive JSON serialization or structured clone — never expect them from deserialized data","Use Symbol.for(key) in registries so both sides share the same symbol instance"],"tags":["typescript","type-assertion","symbol","validation"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}