I have an input to my component that I declared like this.
@Input() rows: (string | number)[][];
I understand this is an array of strintegers (string
or number
), which I have an array of. So the data is a matrix, two dimensions, with strintegers (of floaties but in my case, it's not).
Realizing that not each row will have the same element count, I had to re-work the matrix into a dictionary, i.e. an array of objects (where the objects have properties we know nothing about, except that those are strintegers only). This is my best attempt.
@Input() rows: { [key: string]: (string | number) }[];
While the computer seems to accept it, I fear two things. First one being that it's plain wrong syntax and that I'm only ignorant of the issue due to poor testing. Second one being that regardless of correctness, I've created an atrocious enigma no eyes should ever behold (i.e. there's a perfectly neat way to express the same data structure).
How would one go about declaring a type as specified above in a better way than the one suggested?