mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 22:11:24 -05:00
Refactor: Implement type safety plan
This commit is contained in:
@@ -14,6 +14,23 @@ interface EntityCache {
|
||||
companies: Map<string, { id: string; name: string }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic submission content type
|
||||
*/
|
||||
interface GenericSubmissionContent {
|
||||
name?: string;
|
||||
entity_id?: string;
|
||||
entity_name?: string;
|
||||
park_id?: string;
|
||||
ride_id?: string;
|
||||
company_id?: string;
|
||||
manufacturer_id?: string;
|
||||
designer_id?: string;
|
||||
operator_id?: string;
|
||||
property_owner_id?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of entity name resolution
|
||||
*/
|
||||
@@ -46,7 +63,7 @@ export interface ResolvedEntityNames {
|
||||
*/
|
||||
export function resolveEntityName(
|
||||
submissionType: string,
|
||||
content: any,
|
||||
content: GenericSubmissionContent | null | undefined,
|
||||
entityCache: EntityCache
|
||||
): ResolvedEntityNames {
|
||||
let entityName = content?.name || 'Unknown';
|
||||
@@ -134,7 +151,7 @@ export function getEntityDisplayName(
|
||||
* @param submissions - Array of submission objects
|
||||
* @returns Object containing Sets of IDs for each entity type
|
||||
*/
|
||||
export function extractEntityIds(submissions: any[]): {
|
||||
export function extractEntityIds(submissions: Array<{ content: unknown; submission_type: string }>): {
|
||||
rideIds: Set<string>;
|
||||
parkIds: Set<string>;
|
||||
companyIds: Set<string>;
|
||||
@@ -144,7 +161,7 @@ export function extractEntityIds(submissions: any[]): {
|
||||
const companyIds = new Set<string>();
|
||||
|
||||
submissions.forEach(submission => {
|
||||
const content = submission.content as any;
|
||||
const content = submission.content as GenericSubmissionContent | null | undefined;
|
||||
if (content && typeof content === 'object') {
|
||||
// Direct entity references
|
||||
if (content.ride_id) rideIds.add(content.ride_id);
|
||||
|
||||
Reference in New Issue
Block a user