diff --git a/client/src/utils/pushOrSet.ts b/client/src/utils/pushOrSet.ts index de24c991c44..b38886bd86b 100644 --- a/client/src/utils/pushOrSet.ts +++ b/client/src/utils/pushOrSet.ts @@ -1,6 +1,12 @@ -export function pushOrSet(object: { [index: string | number]: any[] }, key: string | number, value: any) { +/** + * Pushes a value to an array in an object, if the array exists. Else creates a new array containing value. + * @param object Object which contains array + * @param key Key which array is in + * @param value Value to push + */ +export function pushOrSet(object: { [key in K]: Array }, key: K, value: T) { if (key in object) { - object[key].push(value); + object[key]!.push(value); } else { object[key] = [value]; }