mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 06:11:12 -05:00
feat: Implement full type safety plan
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user