You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TS2536: Type 'unique symbol' cannot be used to index type 'T'. #21912
constSTR='a string literal';constSYM=Symbol('a unique symbol');constvalue={[STR]: 'foo',[SYM]: 42,};typeTypeOfStr<Textends{[STR]: any;}>=T[typeofSTR];// OKtypeTypeOfSym<Textends{[SYM]: any;}>=T[typeofSYM];// ERROR// ^^^^^^^^^^^// Type 'unique symbol' cannot be used to index type 'T'typeT1=TypeOfStr<typeofvalue>;// T1 is stringtypeT2=TypeOfSym<typeofvalue>;// T2 is number
Expected behavior:
No errors. If it works for string literal types, it seems it should also work for unique symbol types.
Actual behavior:
TS2536 error with unique symbol as shown above. But the type is still correctly inferred on the last line.
Activity
mhegazy commentedon Mar 8, 2018
Should be fixed by #22339