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
{ [prop]() { } }[prop] fails with Type 'symbol' cannot be used as an index type. aka ts(2538) if prop: string | symbol. It works fine if prop is either string or symbol.
🔎 Search Terms
union type cannot be used as an index type
Found 2 somewhat relevant issues and a pull request, but they don't seem to directly apply. Please close if duplicate:
Bug Report
{ [prop]() { } }[prop]
fails withType 'symbol' cannot be used as an index type.
akats(2538)
ifprop: string | symbol
. It works fine ifprop
is eitherstring
orsymbol
.🔎 Search Terms
union type cannot be used as an index type
Found 2 somewhat relevant issues and a pull request, but they don't seem to directly apply. Please close if duplicate:
Type 'string' cannot be used to index type 'T'
when indexing a generic function parameter #47357🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Type 'symbol' cannot be used as an index type.
🙂 Expected behavior
No type error since both symbol and string are allowed index types.
The text was updated successfully, but these errors were encountered: