Looking for a solution where an interface consists of a fixed property and an optional property, both being of type string
.
export interface Test{
[index: string]: {
'list': string[]; // <<< throws TS2411 error
[index: string]: number;
}
}
An issue arises with TS error
TS2411: Property 'list' of type 'string[]' is not assignable to string index type 'number'.
Any suggestions on how to resolve this?
Note that the list
element will be present within each root index object, while all other properties (if any) are supposed to be of type number.
If I modify the interface like this:
export interface Test{
[index: string]: {
'list': string[];
[index: string]?: number; // <<< throws TS7008 error
}
}
I encounter the error message
TS7008: Member 'number' implicitly has an 'any' type.