I have an object like this:
{
"web.company.name" : "Name",
"web.company.vat_code" : "VAT code",
"web.company.address" : "Address",
"web.person.name" : "Person name",
"web.person.phone" : "Phone",
}
and I'm looking a way to make it type in structure of
{
company: {
"web.company.name" : "Name",
"web.company.vat_code" : "VAT code",
"web.company.address" : "Address",
},
person: {
"web.person.name" : "Person name",
"web.person.phone" : "Phone",
}
}
I have all those [company, name ] as namespaces written down, but if I'm trying to do a record, it includes all values to each namespace:
const NAMESPACES = ["company","person"] as const;
export type Namespace = (typeof NAMESPACES)[number];
type Resources = Record<Namespace, typeof translations>;
how can I narrow it down?