fix: replace any types with proper types in type definitions (12 errors)
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)
This commit is contained in:
parent
c4172ef411
commit
4212ec0f6f
5 changed files with 50 additions and 15 deletions
|
|
@ -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<any>[]
|
||||
data: AppleMusicResource<AppleMusicArtistAttributes>[]
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<string, any>
|
||||
attrs?: Record<string, unknown>
|
||||
content?: TiptapNode[]
|
||||
marks?: Array<{
|
||||
type: string
|
||||
attrs?: Record<string, any>
|
||||
attrs?: Record<string, unknown>
|
||||
}>
|
||||
text?: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue