Add explicit types to removeUndefinedProps

This commit is contained in:
Forrest Wolf 2022-05-25 11:32:26 -04:00
parent 40fd467f22
commit ccf8ffb0b5

View File

@ -1,9 +1,10 @@
import { union } from 'lodash'
export const removeUndefinedProps = <T>(obj: T): T => {
const newObj: any = {}
export const removeUndefinedProps = <T extends object>(obj: T): Partial<T> => {
const newObj: Partial<T> = {}
for (const key of Object.keys(obj)) {
const keys = Object.keys(obj) as Array<keyof T>
for (const key of keys) {
if ((obj as any)[key] !== undefined) newObj[key] = (obj as any)[key]
}