We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS2536: Type cannot be used to index
v4.9.5
Playground Link
type Obj = { a: { b: { c: unknown } } }; type ReMap = { [P in keyof Obj]: { [M in keyof Obj[P]]: Obj[P][M]["c"] } };
Code below throws TS2536: Type "c" cannot be used to index type 'Obj[P][M]'
No error?
Could be related to #21760
The text was updated successfully, but these errors were encountered:
@MartinJohns, I updated the issue, could you please explain what I'm doing wrong?
Sorry, something went wrong.
I think this is just a duplicate of the one you linked.
Anyway this code is equivalent and works well:
type Obj = { a: { b: { c: string } } }; type GetC<T> = T extends { c: infer O } ? O : never; type ReMap = { [P in keyof Obj]: { [M in keyof Obj[P]]: GetC<Obj[P][M]>; } };
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
π Search Terms
TS2536: Type cannot be used to index
π Version & Regression Information
v4.9.5
β― Playground Link
Playground Link
π» Code
π Actual behavior
Code below throws TS2536: Type "c" cannot be used to index type 'Obj[P][M]'
π Expected behavior
No error?
Related?
Could be related to #21760
The text was updated successfully, but these errors were encountered: