Hello I want to create a type for an object like this:
const z = {
name: { // this one is special
buty: ['qqqq']
},
lipa: ['xxx'],
// more keys here
};
Bacially it is an object like this
type Test = {
[key: string]: string[]
}
with one small exception. It always has a key name with a little bit different value.
type Special = {
name: {
[key: string]: string[]
}
}
but when I trying to merge these two types
type Test =
{ [key: string]: string[] } &
{ name: { [key: string]: string[] } };
const z: Test = {
name: { // this one is special
buty: ['qqqq']
},
lipa: ['xxx'],
// more keys here
};
I get an error Type '{ buty: string[]; }' is missing the following properties from type 'string[]': length, pop, push, concat, and 26 more.(2322)
.
Is it possible to create a type for an object like this?