remove any type

add annotation
This commit is contained in:
Laila Los
2023-03-15 19:20:30 +01:00
committed by mvdbeek
parent bd753160bb
commit 08b4536bd8
+8 -2
View File
@@ -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<T, K extends string | number | symbol>(object: { [key in K]: Array<T> }, key: K, value: T) {
if (key in object) {
object[key].push(value);
object[key]!.push(value);
} else {
object[key] = [value];
}