example export const prismaArg = < T > ( field ) : T | undefined => { if ( field === undefined || field === null ) { return undefined ; } return field ; } ; /** Recursively removes nullability from nested object values */ type ObjectWithoutNulls < T > = { [ K in keyof T ] : T [ K ] extends string | number | undefined | null ? Exclude < T [ K ] , null > : ObjectWithoutNulls < Exclude < T [ K ] , null > > ; } ; example export const prismaArgObject = < T extends Partial < Record < keyof T , T [ keyof T ] > > | undefined > ( field ) : ObjectWithoutNulls < T > => { const newObject = field ; if ( ! newObject || ! field ) { return undefined ; } Object . entries ( field ) . forEach ( ( [ key , value ] ) => { if ( typeof value === 'object' ) { newObject [ key ] = prismaArgObject ( value ) ; } else { newObject [ key ] = prismaArg ( value ) ; } } ) ; return newObject ; } ;