I have some utils that looks like that :
export const localStorageToPaginationOptions = <T extends LocalStorage, U>({
searchTerm,
filters,
sortBy,
orderAsc,
...props
}: T & U): PaginationOptions | U => ({
...props,
search: searchTerm,
orderMode: orderAsc ? OrderMode.asc : OrderMode.desc,
orderBy: sortBy,
filters,
});
I would like the function to return either the PaginationOptions type or the U type if it has been declared in the function call. Is there anyway of doing that ?