Fix: Resolve type errors in page components

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 02:56:29 +00:00
parent 516f7c4c41
commit 88403f04f5
4 changed files with 45 additions and 22 deletions

22
src/lib/typeAssertions.ts Normal file
View File

@@ -0,0 +1,22 @@
/**
* Type assertion helpers for TypeScript strict mode compatibility
* These help bridge database types (null) with application types (undefined)
*/
export function nullToUndefined<T>(value: T | null): T | undefined {
return value === null ? undefined : value;
}
export function convertNullsToUndefined<T extends Record<string, any>>(obj: T): { [K in keyof T]: T[K] extends (infer U | null) ? (U | undefined) : T[K] } {
const result: any = {};
for (const key in obj) {
const value = obj[key];
result[key] = value === null ? undefined : value;
}
return result;
}
// Type guard for checking if value is not null/undefined
export function isDefined<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}