diff --git a/src/utils/index.ts b/src/utils/index.ts index b019c1366..c0eed6237 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -202,11 +202,14 @@ export const _safewrap_instance_methods = function (obj: Record): v } } -export const _strip_empty_properties = function >(p: T): { [k in keyof T]?: T[k] } { - const ret: Partial = {} +export const _strip_empty_properties = function >( + p: T +): // remove non-string properties from the type and all keys optional +{ [k in keyof T as T[k] extends string ? k : never]?: T[k] } { + const ret = {} as any _each(p, function (v, k) { if (_isString(v) && v.length > 0) { - ;(ret as any)[k] = v + ret[k] = v } }) return ret