feat: Enable TypeScript strict mode

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 00:58:42 +00:00
parent 061c06be29
commit d126be2908
15 changed files with 308 additions and 68 deletions

View File

@@ -137,8 +137,8 @@ export function useEntityCache() {
}
try {
let data: any[] | null = null;
let error: any = null;
let data: unknown[] | null = null;
let error: unknown = null;
// Use type-safe table queries
switch (type) {
@@ -172,18 +172,20 @@ export function useEntityCache() {
}
if (error) {
logger.error(`Error fetching ${type}:`, error);
logger.error(`Error fetching ${type}:`, { error: getErrorMessage(error as Error) });
return [];
}
// Cache the fetched entities
if (data) {
data.forEach((entity: any) => {
setCached(type, entity.id, entity as EntityTypeMap[T]);
(data as Array<Record<string, unknown>>).forEach((entity) => {
if (entity && typeof entity === 'object' && 'id' in entity && 'name' in entity) {
setCached(type, entity.id as string, entity as EntityTypeMap[T]);
}
});
}
return data || [];
return (data as EntityTypeMap[T][]) || [];
} catch (error: unknown) {
logger.error(`Failed to bulk fetch ${type}:`, { error: getErrorMessage(error) });
return [];
@@ -194,7 +196,7 @@ export function useEntityCache() {
* Fetch and cache related entities based on submission content
* Automatically determines which entities to fetch from submission data
*/
const fetchRelatedEntities = useCallback(async (submissions: any[]): Promise<void> => {
const fetchRelatedEntities = useCallback(async (submissions: Array<{ content?: Record<string, string | number>; submission_type?: string }>): Promise<void> => {
const rideIds = new Set<string>();
const parkIds = new Set<string>();
const companyIds = new Set<string>();
@@ -203,20 +205,20 @@ export function useEntityCache() {
submissions.forEach(submission => {
const content = submission.content;
if (content && typeof content === 'object') {
if (content.ride_id) rideIds.add(content.ride_id);
if (content.park_id) parkIds.add(content.park_id);
if (content.company_id) companyIds.add(content.company_id);
if (content.entity_id) {
if (typeof content.ride_id === 'string') rideIds.add(content.ride_id);
if (typeof content.park_id === 'string') parkIds.add(content.park_id);
if (typeof content.company_id === 'string') companyIds.add(content.company_id);
if (typeof content.entity_id === 'string') {
if (submission.submission_type === 'ride') rideIds.add(content.entity_id);
if (submission.submission_type === 'park') parkIds.add(content.entity_id);
if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(submission.submission_type)) {
if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(submission.submission_type || '')) {
companyIds.add(content.entity_id);
}
}
if (content.manufacturer_id) companyIds.add(content.manufacturer_id);
if (content.designer_id) companyIds.add(content.designer_id);
if (content.operator_id) companyIds.add(content.operator_id);
if (content.property_owner_id) companyIds.add(content.property_owner_id);
if (typeof content.manufacturer_id === 'string') companyIds.add(content.manufacturer_id);
if (typeof content.designer_id === 'string') companyIds.add(content.designer_id);
if (typeof content.operator_id === 'string') companyIds.add(content.operator_id);
if (typeof content.property_owner_id === 'string') companyIds.add(content.property_owner_id);
}
});