This is in effort to reduce overall HTML bloat, undefined props still go through the request as `$undefined` and must be explicitly omitted.
4 lines
162 B
TypeScript
4 lines
162 B
TypeScript
export function removeUndefined<T extends object>(obj: T): T {
|
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) as T
|
|
}
|