Imagine receiving data from a search engine in the following format:
const resultDe = { details_de: "Ein paar Informationen", foo_de:{bar:"barDe"}, code: "1C60" }
const resultEn = { details_en: "Some information", foo_en:{bar:"barEn"} code: "1C60" }
You may be aware of the property names, but some properties have language-specific suffixes like _de
or _en
. Is there a way to define such data types using TypeScript?
For instance, can we do something like this:
type Result = {
`details_${lang}`: string;
}