Closed
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