Add explicit types to removeUndefinedProps
This commit is contained in:
parent
40fd467f22
commit
ccf8ffb0b5
|
@ -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]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user