export const setIf = (obj: T, key: K, val: T[K] | undefined) => { if (typeof val !== 'undefined') obj[key] = val as T[K]; };