Add explicit types to removeUndefinedProps
This commit is contained in:
parent
40fd467f22
commit
ccf8ffb0b5
|
@ -1,9 +1,10 @@
|
||||||
import { union } from 'lodash'
|
import { union } from 'lodash'
|
||||||
|
|
||||||
export const removeUndefinedProps = <T>(obj: T): T => {
|
export const removeUndefinedProps = <T extends object>(obj: T): Partial<T> => {
|
||||||
const newObj: any = {}
|
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]
|
if ((obj as any)[key] !== undefined) newObj[key] = (obj as any)[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user