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
An indexed access type { [P in K]: E }[X] should be assignable to an instantiation of E with X substituted for P.
{ [P in K]: E }[X]
E
X
P
This issue was originally reported here.
Mapped type indexed access.
Nightly build
Playground link with relevant code
type ArgMap = { a: number, b: string }; type Func<K extends keyof ArgMap> = (x: ArgMap[K]) => void; type Funcs = { [K in keyof ArgMap]: Func<K> }; function f1<K extends keyof ArgMap>(funcs: Funcs, key: K, arg: ArgMap[K]) { funcs[key](arg); } function f2<K extends keyof ArgMap>(funcs: Funcs, key: K, arg: ArgMap[K]) { const func = funcs[key]; // Type Funcs[K] func(arg); } function f3<K extends keyof ArgMap>(funcs: Funcs, key: K, arg: ArgMap[K]) { const func: Func<K> = funcs[key]; // Error, Funcs[K] not assignable to Func<K> func(arg); }
Unexpected error in example above.
No errors in example above.
The text was updated successfully, but these errors were encountered:
ahejlsberg
Successfully merging a pull request may close this issue.
Bug Report
An indexed access type
{ [P in K]: E }[X]
should be assignable to an instantiation ofE
withX
substituted forP
.This issue was originally reported here.
🔎 Search Terms
Mapped type indexed access.
🕗 Version & Regression Information
Nightly build
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Unexpected error in example above.
🙂 Expected behavior
No errors in example above.
The text was updated successfully, but these errors were encountered: