Bug Report
🔎 Search Terms
extends Symbol
extends Symbol index key
extending Symbol
InjectionKey
cannot be used as an index type
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
// Reference for InjectionKey: https://github.com/vuejs/vue-next/blob/2d4f4554349db6b07027d0c626f56c48d0233f67/packages/runtime-core/src/apiInject.ts#L6
interface InjectionKey<T> extends Symbol {}
interface SomeInterface { foo: string }
const key: InjectionKey<SomeInterface> = Symbol()
const records: Record<string | symbol, any> = {};
records['a-string']; // Works
records[Symbol()]; // Works
records[key]; // Doesn't work
records[key as symbol]; // Works
// Assignability tests
const _key1: symbol = key; // Doesn't work
const _key2: symbol = key as symbol; // Works
// Casting tests
key as symbol; // Works (Expected)
key as string; // Doesn't work (Expected)
key as number; // Doesn't work (Expected)
// ...
const sym = Symbol();
sym as symbol; // Works (Expected)
sym as string; // Doesn't work (Expected)
sym as number; // Doesn't work (Expected)
// ...
🙁 Actual behavior
Interfaces that extend Symbol(e.g. InjectionKey) can't be used as symbol directly although they can be explicitly cast.
🙂 Expected behavior
Interfaces that extend Symbol can be used as symbol, which includes being used as index types.
Bug Report
🔎 Search Terms
extends Symbol
extends Symbol index key
extending Symbol
InjectionKey
cannot be used as an index type
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Interfaces that extend
Symbol(e.g.InjectionKey) can't be used assymboldirectly although they can be explicitly cast.🙂 Expected behavior
Interfaces that extend
Symbolcan be used assymbol, which includes being used as index types.