Symbol To String Coercion Error
Quick summary
You concatenated a Symbol with a string using + or templated it without String() — JavaScript throws because Symbols cannot coerce implicitly.
Why this happens
Using
symbol + ''or template literals without an explicit String() callPassing a Symbol where a string is expected without explicit conversion
Mixing Symbol keys with string operations in object property access
Minimal example
const id = Symbol('user');
console.log('id: ' + id); // TypeError: Cannot convert a Symbol value to a stringconst id = Symbol('user');
console.log('id: ' + id.description); // 'id: user'The + operator tries to implicitly coerce the Symbol to a string, which is forbidden. Using .description extracts the descriptive string so concatenation works.
How to diagnose
Read the TypeError: 'Cannot convert a Symbol value to a string/number'
Check the operands of + and template literals with typeof
Look for Symbol() values flowing into string-building code
How to fix
Call String(symbol) or symbol.description explicitly to convert
Use symbol.description to get the descriptive string part
Avoid arithmetic with Symbols — convert to a number first if truly needed
How to prevent
Never concatenate Symbols with + — always convert explicitly
Type-check values before string operations when Symbols may be present
Related Resources
Related Glossary
Related Lessons
- Data Types
Learn about Symbols and coercion.