symbolDescriptions
Reports Symbol() calls without description arguments.
✅ This rule is included in the tsstylisticandstylisticStrictpresets.
Creating symbols without descriptions makes debugging difficult, as the symbol’s purpose isn’t clear when inspecting it.
While the description doesn’t affect the symbol’s uniqueness, it appears in the symbol’s string representation and can be accessed via Symbol.prototype.description.
Providing meaningful descriptions helps developers understand the purpose of each symbol during debugging and logging.
Examples
Section titled “Examples”const const uniqueId: typeof uniqueId
uniqueId = var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol();const const privateKey: typeof privateKey
privateKey = var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol();
class class MyClass
MyClass { [var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol()]() { return "method"; }}const const uniqueId: typeof uniqueId
uniqueId = var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol("uniqueId");const const privateKey: typeof privateKey
privateKey = var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol("privateKey");
class class MyClass
MyClass { [var Symbol: SymbolConstructor(description?: string | number) => symbol
Returns a new unique Symbol value.
Symbol("customMethod")]() { return "method"; }}
// Well-known symbols don't need descriptionsconst const iterator: symbol
iterator = var Symbol: SymbolConstructor
Symbol.SymbolConstructor.iterator: typeof Symbol.iterator
A method that returns the default iterator for an object. Called by the semantics of the
for-of statement.
iterator;
// Symbol.for() creates global symbols with identifiersconst const globalSymbol: typeof globalSymbol
globalSymbol = var Symbol: SymbolConstructor
Symbol.SymbolConstructor.for(key: string): symbol
Returns a Symbol object from the global symbol registry matching the given key if found.
Otherwise, returns a new symbol with this key.
for("app.config");Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you’re working in a codebase where symbol descriptions aren’t important for debugging purposes, or if you dynamically create many anonymous symbols, you might choose to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useSymbolDescription - ESLint:
symbol-description - Oxlint:
eslint/symbol-description