Improve error message for union indexing #30241
Labels
Domain: Error Messages
The issue relates to error messaging
Experience Enhancement
Noncontroversial enhancements
Good First Issue
Well scoped, documented and has the green light
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
Search Terms
union, index
Suggestion
When a type union is used to index into a type with no index signature, if the property names match up correctly the access is allowed and Typescript does the "right thing" anyway. If the property names don't match up, and there's no index signature, an error is given, but it might not be the most helpful error.
Use Cases
I have a type that's a union of string literals, and I want to create some mapping for them. But if I forget a single property name, the error doesn't help me find what was missing
Examples
Related
#14951
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: