-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
The following code:
type K = "foo" | "bar";
interface SomeType {
[prop: K]: any;
}
Gives this error message:
An index signature parameter type cannot be a union type. Consider using a mapped object type instead.
Nobody knows what mapped object types are, so let's give them a quick fix that
- Switches the index signature to a mapped type
- Moves other members to a separate object type that gets combined with an intersection type
- Changes the containing object type to a type alias if the containing object type is an interface
- Intersects with all the
extends
clauses if the containing object type is an interface and has anyextends
clauses
dannycochran, johnnyreilly, zdila, amaury1093, Val0429 and 273 moresamuelgrigolato, breck7, kildareflare, ibrod83, fulminmaxi and 5 moreshijiezhou1, rokinsky and ricardo-rp
Metadata
Metadata
Assignees
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript