-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
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
Const indexed access issue β should attempt widening to a mapped type #51156
Comments
This is working as intended.
f1<"a" | "b">("a", "abc")
f1<"a" | "b">("b", 123) |
The error is correct, though if you formulate your arguments to a specific pattern, a convenient soundness hole will be created for you. See #47109 |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
@ahejlsberg This issue seems nearly identical to #47368, but this time for const object types which are assignable to the mapped type.
π Search Terms
const indexed access; object literal indexed access; object literal widen; widen mapped type
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Unexpected error in example above.
It's unexpected because throwing away type information makes this type check correctly, by widening with either
const funcs: Funcs
(all examples) orconst func: Funcs[K]
(in f2). So the compiler actually is able to confirm that indexed type is assignable to the mapped type, it just doesn't try without being explicitly prompted.π Expected behavior
No errors in example above.
The text was updated successfully, but these errors were encountered: