interface Config {
translations: ConfigTranslations
}
type ConfigTranslations = {
$load?: {
groups: string[]
routes: string[]
}[]
$directory?: {
main?: string
pages?: string
}
} & {
[group: string]: {
[locale: string]: DeepStringRecord
}
}
type DeepStringRecord = {
[key: string]: string | DeepStringRecord
}
const config: Config = {
translations: { // Type '{ routes: string[]; groups: string[]; }[]' is not assignable to type '{ [locale: string]: DeepStringRecord; }'
$load: [
{
routes: ["/group$"],
groups: ["^group"],
},
{
routes: ["/group"],
groups: ["^group2"],
},
],
common: {
en: {
foo: "bar",
bar: {
baz: "foo",
},
},
}
}
}
I typed ConfigTranslations, so it can have 2 special keys but the mapped type overrides these keys and throws an error when trying to fill them. Do you have an idea on how to fix this ?