Skip to content

Commit 094b37b

Browse files
committed
Fix tsc errors.
1 parent 0ea0c63 commit 094b37b

File tree

4 files changed

+105
-56
lines changed

4 files changed

+105
-56
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@
4040
"rehype-slug": "^6.0.0",
4141
"remark-toc": "^9.0.0",
4242
"sharp": "^0.34.0",
43-
"tailwindcss": "^3.4.17",
44-
"typescript": "^5.8.3"
43+
"tailwindcss": "^3.4.17"
4544
},
4645
"devDependencies": {
4746
"@types/js-yaml": "^4.0.9",
4847
"prettier": "^3.5.3",
49-
"prettier-plugin-astro": "^0.14.1"
48+
"prettier-plugin-astro": "^0.14.1",
49+
"tsx": "^4.19.3",
50+
"typescript": "^5.8.3"
5051
},
5152
"prettier": {
5253
"proseWrap": "always"

pnpm-lock.yaml

Lines changed: 61 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/config.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
162174
const 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

Comments
 (0)