// dictionary = any number of properties of the same type interface StringDictionary { [key: string]: string; } const obj: StringDictionary = { key1: "value-1", key2: "value-2", keyn: "value-n" }; // record = equivalent to dictionary above const obj: Record<string, string> = { key1: "value-1", key2: "value-2", keyn: "value-n", };
// enums = predefined, but can grow dynamically via the definition enum KeysEnum { FIRST = "firstKey", SECOND = "secondKey", } type EnumDictionary = Record<KeysEnum, string>; const obj: EnumDictionary = { [KeysEnum.FIRST]: "value1", [KeysEnum.SECOND]: "value2", };
This is to make the variable an optional type.
export interface ISearchResult { title: string; listTitle:string; entityName?: string, lookupName?:string, lookupId?:string }
Otherwise, declared variables shows undefined
if this variable is not used.
{ entityName?: string; } // equivalent to: { entityName: string | undefined; }