@@ -65,15 +65,19 @@ async function getCollectionsData() {
6565 const sessionsData = await loadData ( import . meta. env . EP_SESSIONS_API ) ;
6666
6767 // Create indexed versions for efficient lookups
68- const speakersById = Object . entries ( speakersData ) . reduce (
68+ const speakersById = Object . entries (
69+ speakersData as Record < string , { } >
70+ ) . reduce (
6971 ( acc , [ id , speaker ] : [ string , any ] ) => {
7072 acc [ id ] = { id, ...speaker } ;
7173 return acc ;
7274 } ,
7375 { } as Record < string , any >
7476 ) ;
7577
76- const sessionsById = Object . entries ( sessionsData ) . reduce (
78+ const sessionsById = Object . entries (
79+ sessionsData as Record < string , { } >
80+ ) . reduce (
7781 ( acc , [ id , session ] : [ string , any ] ) => {
7882 acc [ id ] = { id, ...session } ;
7983 return acc ;
@@ -93,13 +97,15 @@ const speakers = defineCollection({
9397 loader : async ( ) : Promise < any > => {
9498 const { speakersData, sessionsById } = await getCollectionsData ( ) ;
9599
96- return Object . values ( speakersData ) . map ( ( speaker : any ) => ( {
97- id : speaker . slug ,
98- ...speaker ,
99- submissions : ( speaker . submissions || [ ] )
100- . filter ( ( sessionId : string ) => sessionId in sessionsById )
101- . map ( ( sessionId : string ) => sessionsById [ sessionId ] . slug ) ,
102- } ) ) ;
100+ return Object . values ( speakersData as Record < string , { } > ) . map (
101+ ( speaker : any ) => ( {
102+ id : speaker . slug ,
103+ ...speaker ,
104+ submissions : ( speaker . submissions || [ ] )
105+ . filter ( ( sessionId : string ) => sessionId in sessionsById )
106+ . map ( ( sessionId : string ) => sessionsById [ sessionId ] . slug ) ,
107+ } )
108+ ) ;
103109 } ,
104110 schema : z . object ( {
105111 code : z . string ( ) ,
@@ -122,13 +128,15 @@ const sessions = defineCollection({
122128 loader : async ( ) : Promise < any > => {
123129 const { sessionsData, speakersById } = await getCollectionsData ( ) ;
124130
125- return Object . values ( sessionsData ) . map ( ( session : any ) => ( {
126- id : session . slug ,
127- ...session ,
128- speakers : ( session . speakers || [ ] )
129- . filter ( ( speakerId : string ) => speakerId in speakersById )
130- . map ( ( speakerId : string ) => speakersById [ speakerId ] . slug ) ,
131- } ) ) ;
131+ return Object . values ( sessionsData as Record < string , { } > ) . map (
132+ ( session : any ) => ( {
133+ id : session . slug ,
134+ ...session ,
135+ speakers : ( session . speakers || [ ] )
136+ . filter ( ( speakerId : string ) => speakerId in speakersById )
137+ . map ( ( speakerId : string ) => speakersById [ speakerId ] . slug ) ,
138+ } )
139+ ) ;
132140 } ,
133141 schema : z . object ( {
134142 code : z . string ( ) ,
@@ -159,13 +167,23 @@ const sessions = defineCollection({
159167 } ) ,
160168} ) ;
161169
170+ interface ScheduleData {
171+ days : Record < string , any > ;
172+ }
173+
162174const days = defineCollection ( {
163175 loader : async ( ) : Promise < any [ ] > => {
164- const schedule = await loadData ( import . meta. env . EP_SCHEDULE_API ) ;
165-
166- if ( Object . keys ( schedule ) . length === 0 ) {
167- return schedule ;
176+ // Type assertion to specify the expected structure of the loaded data
177+ const schedule = ( await loadData (
178+ import . meta. env . EP_SCHEDULE_API
179+ ) ) as ScheduleData ;
180+
181+ // Check if schedule is empty
182+ if ( ! schedule || Object . keys ( schedule ) . length === 0 ) {
183+ return [ ] ;
168184 }
185+
186+ // Now TypeScript knows schedule has days property
169187 return Object . entries ( schedule . days ) . map ( ( [ date , data ] : [ string , any ] ) => ( {
170188 id : date ,
171189 ...data ,
0 commit comments