export const shake = (obj: T): Shook => { if (obj == null) return obj if (typeof obj !== 'object') return obj // eslint-disable-next-line @typescript-eslint/consistent-type-assertions const initialValue = {} as Shook return Object.entries(obj).reduce>((acc, [k, v]) => { if (v === undefined) return acc return { ...acc, [k]: v } }, initialValue) } type Shook = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] }