We have the following format from out backend, which has data part that is just tabular data and a meta part that describes the columns in the table. The metadata holds the information about the type for each column.
Example
{
meta: [
{name: "foo", type: "NUMBER"},
{name: "bar", type: "STRING"},
{name: "baz", type: "TIMESTAMP"},
],
data:[
[1, "a", 12121232],
[2, "b", 12121232],
[3, "c", 12121232],
]
}
Is there any way to type the relation between meta and data in TypeScript?
The goal is to have this function to be typechecked successfully, so i can use the type info from the meta info instead of checking the content of every table cell:
const fn = (data:Data) => {
if(data.meta[1].type ==='STRING'){
data.data[0][1].concat('-bar')
}
}