From 4212ec0f6fdc47ce45942a899c347e8c0f97edb3 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 24 Nov 2025 01:30:35 -0800 Subject: [PATCH] fix: replace any types with proper types in type definitions (12 errors) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 Batch 1: Type Definitions Replaced any types with proper TypeScript types across 5 type definition files: - apple-music.ts: Added AppleMusicArtistAttributes, changed type guards to use unknown - editor.ts: Changed any to unknown for flexible block/node attributes - lastfm.ts: Defined editorialNotes structure, changed rawResponse to unknown - project.ts: Changed caseStudyContent to EditorData type - photos.ts: Defined ColorPalette interface for color data Progress: 207 → 199 errors (103 → 91 any-type errors) --- src/lib/types/apple-music.ts | 38 +++++++++++++++++++++++++++++------- src/lib/types/editor.ts | 6 +++--- src/lib/types/lastfm.ts | 7 +++++-- src/lib/types/photos.ts | 8 +++++++- src/lib/types/project.ts | 6 ++++-- 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/lib/types/apple-music.ts b/src/lib/types/apple-music.ts index 2b117de..5644684 100644 --- a/src/lib/types/apple-music.ts +++ b/src/lib/types/apple-music.ts @@ -40,6 +40,13 @@ export interface AppleMusicAttributes { url: string } +export interface AppleMusicArtistAttributes { + name: string + artwork?: AppleMusicArtwork + genreNames?: string[] + url?: string +} + export interface AppleMusicTrackAttributes { albumName: string artistName: string @@ -64,7 +71,7 @@ export interface AppleMusicTrackAttributes { export interface AppleMusicRelationships { artists?: { - data: AppleMusicResource[] + data: AppleMusicResource[] href?: string next?: string } @@ -117,16 +124,33 @@ export interface AppleMusicErrorResponse { } // Type guards -export function isAppleMusicError(response: any): response is AppleMusicErrorResponse { - return response && 'errors' in response && Array.isArray(response.errors) +export function isAppleMusicError(response: unknown): response is AppleMusicErrorResponse { + return ( + typeof response === 'object' && + response !== null && + 'errors' in response && + Array.isArray((response as AppleMusicErrorResponse).errors) + ) } -export function isAppleMusicAlbum(resource: any): resource is AppleMusicAlbum { - return resource && resource.type === 'albums' && 'attributes' in resource +export function isAppleMusicAlbum(resource: unknown): resource is AppleMusicAlbum { + return ( + typeof resource === 'object' && + resource !== null && + 'type' in resource && + (resource as AppleMusicAlbum).type === 'albums' && + 'attributes' in resource + ) } -export function isAppleMusicTrack(resource: any): resource is AppleMusicTrack { - return resource && resource.type === 'songs' && 'attributes' in resource +export function isAppleMusicTrack(resource: unknown): resource is AppleMusicTrack { + return ( + typeof resource === 'object' && + resource !== null && + 'type' in resource && + (resource as AppleMusicTrack).type === 'songs' && + 'attributes' in resource + ) } // Helper function to get high-resolution artwork URL diff --git a/src/lib/types/editor.ts b/src/lib/types/editor.ts index 11e9cb4..6671944 100644 --- a/src/lib/types/editor.ts +++ b/src/lib/types/editor.ts @@ -20,7 +20,7 @@ export interface EditorBlock { items?: string[] caption?: string url?: string - [key: string]: any + [key: string]: unknown } } @@ -33,11 +33,11 @@ export interface EditorSaveData { // Tiptap/Edra content nodes export interface TiptapNode { type: string - attrs?: Record + attrs?: Record content?: TiptapNode[] marks?: Array<{ type: string - attrs?: Record + attrs?: Record }> text?: string } diff --git a/src/lib/types/lastfm.ts b/src/lib/types/lastfm.ts index 06a6ded..81c4b33 100644 --- a/src/lib/types/lastfm.ts +++ b/src/lib/types/lastfm.ts @@ -39,7 +39,10 @@ export interface Album { trackCount?: number recordLabel?: string copyright?: string - editorialNotes?: any + editorialNotes?: { + short?: string + standard?: string + } isComplete?: boolean tracks?: Array<{ name: string @@ -51,7 +54,7 @@ export interface Album { searchQuery?: string storefront?: string responseTime?: number - rawResponse?: any + rawResponse?: unknown matchType?: 'exact' | 'fuzzy' | 'single' searchAttempts?: number } diff --git a/src/lib/types/photos.ts b/src/lib/types/photos.ts index 4a6da12..4dab3c4 100644 --- a/src/lib/types/photos.ts +++ b/src/lib/types/photos.ts @@ -9,6 +9,12 @@ export interface ExifData { location?: string } +export interface ColorPalette { + hex?: string + rgb?: [number, number, number] + population?: number +} + export interface Photo { id: string src: string @@ -17,7 +23,7 @@ export interface Photo { width: number height: number dominantColor?: string - colors?: any + colors?: ColorPalette[] aspectRatio?: number exif?: ExifData createdAt?: string diff --git a/src/lib/types/project.ts b/src/lib/types/project.ts index 720f66b..a3dd406 100644 --- a/src/lib/types/project.ts +++ b/src/lib/types/project.ts @@ -1,3 +1,5 @@ +import type { EditorData } from './editor' + export type ProjectStatus = 'draft' | 'published' | 'list-only' | 'password-protected' export type ProjectType = 'work' | 'labs' @@ -13,7 +15,7 @@ export interface Project { featuredImage: string | null logoUrl: string | null externalUrl: string | null - caseStudyContent: any | null + caseStudyContent: EditorData | null backgroundColor: string | null highlightColor: string | null projectType: ProjectType @@ -43,7 +45,7 @@ export interface ProjectFormData { logoUrl: string status: ProjectStatus password: string - caseStudyContent: any + caseStudyContent: EditorData showFeaturedImageInHeader: boolean showBackgroundColorInHeader: boolean showLogoInHeader: boolean