As already confirmed in @Nicholas Tower's comment, your approach is correct.
There is, however, a small improvement I would like to suggest: you have three strings in your type definition. However, those three strings actually mean completely different things. So, what I would do, is give them a type alias:
type Uri = string;
type Language = string;
type Name = string;
interface Food {
id: number;
url: Uri;
commonNames: {
[index: Language]: Name[];
};
}
These are only aliases, so they do not actually change anything about the typing. But, they make it a little bit clearer what those attributes are about.
Also, a type alias gives you a place that you can attach a TSDoc comment to:
/**
/ * A globally unique, monotonically increasing identifier for a dictionary entry
**/
type Id = number;
/**
/ * A URI
**/
type Uri = string;
/**
/ * A URI referencing a picture of the food
**/
type PictureUri = Uri;
/**
/ * An ISO 639-1:2002 Alpha-2 Language Code
**/
type Language = string;
/**
/ * The name of the food
**/
type Name = string;
interface Food {
id: Id;
url: PictureUri;
commonNames: {
[index: Language]: Name[];
};
}
This is of course an extreme example, but it shows the value of type aliases for documentation.
type Language = 'de' | 'en' | 'th'andcommonNames: { [index in Language]: string[] }