feat: Implement full type safety plan

This commit is contained in:
gpt-engineer-app[bot]
2025-10-20 00:40:47 +00:00
parent d9a912f443
commit db60759b9b
11 changed files with 271 additions and 23 deletions

View File

@@ -46,5 +46,25 @@ export interface TempRideModelData {
banner_assignment?: number | null;
card_assignment?: number | null;
};
_technical_specifications?: unknown[];
_technical_specifications?: TechnicalSpecification[];
}
export interface TechnicalSpecification {
id?: string;
spec_name: string;
spec_value: string;
spec_type: 'string' | 'number' | 'boolean' | 'date';
category?: string;
unit?: string;
display_order: number;
}
export interface CoasterStat {
id?: string;
stat_type: string;
value: string;
unit?: string;
}
export type CoasterStatValue = string | number | null;
export type TechnicalSpecValue = string | number | null;

View File

@@ -9,7 +9,7 @@ export interface UserIdentity {
email?: string;
full_name?: string;
avatar_url?: string;
[key: string]: any;
[key: string]: unknown;
};
provider: 'google' | 'discord' | 'email' | 'github' | string;
created_at: string;

View File

@@ -52,3 +52,29 @@ export interface LocationInfoSettings {
accessibility: AccessibilityOptions;
unitPreferences: UnitPreferences;
}
/**
* Location data structure
*/
export interface LocationData {
country?: string;
state_province?: string;
city?: string;
latitude?: number;
longitude?: number;
}
/**
* Type guard for location data
*/
export function isLocationData(data: unknown): data is LocationData {
if (typeof data !== 'object' || data === null) return false;
const loc = data as Record<string, unknown>;
return (
(loc.country === undefined || typeof loc.country === 'string') &&
(loc.state_province === undefined || typeof loc.state_province === 'string') &&
(loc.city === undefined || typeof loc.city === 'string') &&
(loc.latitude === undefined || typeof loc.latitude === 'number') &&
(loc.longitude === undefined || typeof loc.longitude === 'number')
);
}

View File

@@ -29,6 +29,22 @@ export interface NormalizedPhoto {
// Photo data source types
export type PhotoDataSource =
| { type: 'review'; photos: any[] }
| { type: 'submission_jsonb'; photos: any[] }
| { type: 'review'; photos: PhotoItem[] }
| { type: 'submission_jsonb'; photos: PhotoItem[] }
| { type: 'submission_items'; items: PhotoSubmissionItem[] };
// Type guard for photo arrays
export function isPhotoItem(data: unknown): data is PhotoItem {
return (
typeof data === 'object' &&
data !== null &&
'id' in data &&
'url' in data &&
'filename' in data
);
}
// Type guard for photo arrays
export function isPhotoItemArray(data: unknown): data is PhotoItem[] {
return Array.isArray(data) && (data.length === 0 || isPhotoItem(data[0]));
}