From 08b4536bd88627d2dec0f5492ca42571616da5d8 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Tue, 14 Mar 2023 11:03:33 +0100 Subject: [PATCH] remove any type add annotation --- client/src/utils/pushOrSet.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/utils/pushOrSet.ts b/client/src/utils/pushOrSet.ts index de24c991c445..b38886bd86b6 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]; }