Search Terms
Suggestion
Use this:
declare function Symbol (x?: string | number): symbol
declare namespace Symbol {
const prototype: symbol
const iterator: unique symbol
}
Or this:
interface SymbolConstructor {
(x?: string | number): symbol
readonly prototype: symbol
readonly iterator: unique symbol
}
declare var Symbol: SymbolConstructor
Instead of this:
interface SymbolConstructor {
(x?: string | number): symbol
readonly prototype: symbol
readonly iterator: symbol
}
declare var Symbol: SymbolConstructor
Use Cases
Right now, I can do this for custom unique symbol:
const foo = Symbol() // unique symbol
const bar: typeof foo = foo
const baz: {
[foo]: number
} = {
[bar]: 123
}
But not for Symbol.*
// Expecting 'typeof Symbol.iterator' but received 'symbol'
const iterator: typeof Symbol.iterator = Symbol.iterator
// This is not working
const iterable: Iterable<number> = {
* [iterator] () {
yield * [0, 1, 2, 3]
}
}
Checklist
My suggestion meets these guidelines:
Playground Link (This also works)
Related Issue
Search Terms
Suggestion
Use this:
Or this:
Instead of this:
Use Cases
Right now, I can do this for custom
unique symbol:But not for
Symbol.*Checklist
My suggestion meets these guidelines:
Playground Link (This also works)
Related Issue