fix: replace any types in route pages (10 errors)

Phase 1 Batch 3: Route Pages type safety improvements

Fixed 10 any-type errors across 7 route page files:

1. src/routes/+page.ts (1 error)
   - Added PaginationInfo interface for fetchProjects return type

2. src/routes/admin/+layout.svelte (1 error)
   - Changed children prop from any to Snippet type

3. src/routes/admin/albums/+page.svelte (1 error)
   - Changed Album.content from any to EditorData type

4. src/routes/admin/universe/+page.svelte (1 error)
   - Changed form prop from any to Record<string, unknown> | null | undefined

5. src/routes/albums/[slug]/+page.svelte (4 errors)
   - Added AlbumPhoto and AlbumData interfaces
   - Fixed photo map parameters to use AlbumPhoto
   - Fixed extractContentPreview to accept EditorData | null
   - Fixed generateAlbumJsonLd to accept AlbumData

6. src/routes/albums/+page.svelte (1 error)
   - Changed coverPhoto.colors from any to ColorPalette[]

7. src/routes/photos/[id]/+page.svelte (1 error)
   - Changed navigateToPhoto parameter from any to PhotoItem | null

Progress: 67 any-type errors remaining (down from 77)
This commit is contained in:
Justin Edmund 2025-11-24 02:01:47 -08:00
parent 9da0232d45
commit f31d02d51c
7 changed files with 44 additions and 11 deletions

View file

@ -40,9 +40,16 @@ async function fetchRecentAlbums(fetch: typeof window.fetch): Promise<Album[]> {
return musicData.albums
}
interface PaginationInfo {
total: number
limit: number
offset: number
hasMore: boolean
}
async function fetchProjects(
fetch: typeof window.fetch
): Promise<{ projects: Project[]; pagination: any }> {
): Promise<{ projects: Project[]; pagination: PaginationInfo | null }> {
const response = await fetch(
'/api/projects?projectType=work&includeListOnly=true&includePasswordProtected=true'
)

View file

@ -2,8 +2,9 @@
import { page } from '$app/stores'
import AdminNavBar from '$lib/components/admin/AdminNavBar.svelte'
import type { LayoutData } from './$types'
import type { Snippet } from 'svelte'
const { children, data } = $props<{ children: any; data: LayoutData }>()
const { children, data } = $props<{ children: Snippet; data: LayoutData }>()
const currentPath = $derived($page.url.pathname)
const isLoginRoute = $derived(currentPath === '/admin/login')

View file

@ -10,6 +10,7 @@
import ErrorMessage from '$lib/components/admin/ErrorMessage.svelte'
import Button from '$lib/components/admin/Button.svelte'
import Select from '$lib/components/admin/Select.svelte'
import type { EditorData } from '$lib/types/editor'
interface Photo {
id: number
@ -32,7 +33,7 @@
createdAt: string
updatedAt: string
photos: Photo[]
content?: any
content?: EditorData
_count: {
media: number
}

View file

@ -3,7 +3,7 @@
import type { PageData } from '../posts/$types'
export let data: PageData
export let form: any
export let form: Record<string, unknown> | null | undefined
</script>
<PostsPage {data} {form} />

View file

@ -5,6 +5,7 @@
import { generateMetaTags } from '$lib/utils/metadata'
import { page } from '$app/stores'
import type { PageData } from './$types'
import type { ColorPalette } from '$lib/types/photos'
interface Album {
id: string
@ -21,7 +22,7 @@
width?: number
height?: number
dominantColor?: string
colors?: any
colors?: ColorPalette[]
aspectRatio?: number
caption?: string
}

View file

@ -6,6 +6,29 @@
import { renderEdraContent, getContentExcerpt } from '$lib/utils/content'
import { page } from '$app/stores'
import type { PageData } from './$types'
import type { EditorData } from '$lib/types/editor'
interface AlbumPhoto {
id: number
url: string
caption: string | null
filename: string
width: number | null
height: number | null
}
interface AlbumData {
id: number
slug: string
title: string
description: string | null
content: EditorData | null
location: string | null
date: string | null
createdAt: string
updatedAt: string
photos?: AlbumPhoto[]
}
let { data }: { data: PageData } = $props()
@ -14,7 +37,7 @@
// Transform album data to PhotoItem format for MasonryPhotoGrid
const photoItems = $derived(
album?.photos?.map((photo: any) => ({
album?.photos?.map((photo: AlbumPhoto) => ({
id: `photo-${photo.id}`,
src: photo.url,
alt: photo.caption || photo.filename,
@ -36,7 +59,7 @@
const pageUrl = $derived($page.url.href)
// Helper to get content preview using Edra content excerpt utility
const extractContentPreview = (content: any): string => {
const extractContentPreview = (content: EditorData | null): string => {
if (!content) return ''
return getContentExcerpt(content, 155)
}
@ -65,13 +88,13 @@
)
// Generate enhanced JSON-LD for albums with content
const generateAlbumJsonLd = (album: any, pageUrl: string) => {
const generateAlbumJsonLd = (album: AlbumData, pageUrl: string) => {
const baseJsonLd = generateImageGalleryJsonLd({
name: album.title,
description: album.description,
url: pageUrl,
images:
album.photos?.map((photo: any) => ({
album.photos?.map((photo: AlbumPhoto) => ({
url: photo.url,
caption: photo.caption
})) || []

View file

@ -8,7 +8,7 @@
import { spring } from 'svelte/motion'
import { getCurrentMousePosition } from '$lib/stores/mouse'
import type { PageData } from './$types'
import { isAlbum } from '$lib/types/photos'
import { isAlbum, type PhotoItem } from '$lib/types/photos'
import ArrowLeft from '$icons/arrow-left.svg'
import ArrowRight from '$icons/arrow-right.svg'
@ -110,7 +110,7 @@
})
// Handle photo navigation
function navigateToPhoto(item: any) {
function navigateToPhoto(item: PhotoItem | null) {
if (!item) return
// Extract media ID from item.id (could be 'media-123' or 'photo-123')
const mediaId = item.id.replace(/^(media|photo)-/, '')