as title says, have an interface that includes a fixed property and optional property, both of type string
.
export interface Test{
[index: string]: {
'list': string[]; // <<< throws TS2411 error
[index: string]: number;
}
}
This throws TS error TS2411: Property 'list' of type 'string[]' is not assignable to string index type 'number'.
How can I work around that ?
I know that list
element will exist within each root index object, all other properties (if they exist) are of type number.
if I change the interface to:
export interface Test{
[index: string]: {
'list': string[];
[index: string]?: number; // <<< throws TS7008 error
}
}
then I get TS7008: Member 'number' implicitly has an 'any' type.