Let's consider the following:
type Bar = keyof Collection<string>
In this scenario, Bar
denotes the type of keys present in the Collection
object, such as insert
or remove
:
const x: Bar = 'insert'; ✅
But wait, the Collection
also contains some well-known symbol properties:
const y: Bar = Symbol.iterator; ✅
Now, when it comes to using a Pick
type, how can we make reference to a symbol key?
type C = Pick<Collection<string>, 'insert'> ✅
type D = Pick<Collection<string>, Symbol.iterator> ❌
The second instance of Pick
encounters an issue - "Symbol only refers to a type but is being used as a namespace here."