I have an object for an array that can be the following
{
'value1': 1,
'value2': 2
}
or
{
'value1': 'a',
'value2': 'b'
}
or
{
'value1': {'sub1': 1, 'sub2': 2},
'value2': {'sub1': 1, 'sub2': 2}
}
I wanted to type this like this :
export interface TableRow {
[key: string]: string | number | ([key: string] : string) | ([key: string] : number)
}
but it doesn't work.
Is this the only way possible ?
export interface TableRow {
[key: string]: string | number | object
}
interface TableRow { [key: string]: string | number | { [key: string]: string } | { [key: string]: number } }). Is that what you mean by "it doesn't work"? Usually a minimal reproducible example should explicitly describe what the problem is