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
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AppleMusicArtistAttributes {
|
||||||
|
name: string
|
||||||
|
artwork?: AppleMusicArtwork
|
||||||
|
genreNames?: string[]
|
||||||
|
url?: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppleMusicTrackAttributes {
|
export interface AppleMusicTrackAttributes {
|
||||||
albumName: string
|
albumName: string
|
||||||
artistName: string
|
artistName: string
|
||||||
|
|
@ -64,7 +71,7 @@ export interface AppleMusicTrackAttributes {
|
||||||
|
|
||||||
export interface AppleMusicRelationships {
|
export interface AppleMusicRelationships {
|
||||||
artists?: {
|
artists?: {
|
||||||
data: AppleMusicResource<any>[]
|
data: AppleMusicResource<AppleMusicArtistAttributes>[]
|
||||||
href?: string
|
href?: string
|
||||||
next?: string
|
next?: string
|
||||||
}
|
}
|
||||||
|
|
@ -117,16 +124,33 @@ export interface AppleMusicErrorResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type guards
|
// Type guards
|
||||||
export function isAppleMusicError(response: any): response is AppleMusicErrorResponse {
|
export function isAppleMusicError(response: unknown): response is AppleMusicErrorResponse {
|
||||||
return response && 'errors' in response && Array.isArray(response.errors)
|
return (
|
||||||
|
typeof response === 'object' &&
|
||||||
|
response !== null &&
|
||||||
|
'errors' in response &&
|
||||||
|
Array.isArray((response as AppleMusicErrorResponse).errors)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAppleMusicAlbum(resource: any): resource is AppleMusicAlbum {
|
export function isAppleMusicAlbum(resource: unknown): resource is AppleMusicAlbum {
|
||||||
return resource && resource.type === 'albums' && 'attributes' in resource
|
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 {
|
export function isAppleMusicTrack(resource: unknown): resource is AppleMusicTrack {
|
||||||
return resource && resource.type === 'songs' && 'attributes' in resource
|
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
|
// Helper function to get high-resolution artwork URL
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export interface EditorBlock {
|
||||||
items?: string[]
|
items?: string[]
|
||||||
caption?: string
|
caption?: string
|
||||||
url?: string
|
url?: string
|
||||||
[key: string]: any
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,11 +33,11 @@ export interface EditorSaveData {
|
||||||
// Tiptap/Edra content nodes
|
// Tiptap/Edra content nodes
|
||||||
export interface TiptapNode {
|
export interface TiptapNode {
|
||||||
type: string
|
type: string
|
||||||
attrs?: Record<string, any>
|
attrs?: Record<string, unknown>
|
||||||
content?: TiptapNode[]
|
content?: TiptapNode[]
|
||||||
marks?: Array<{
|
marks?: Array<{
|
||||||
type: string
|
type: string
|
||||||
attrs?: Record<string, any>
|
attrs?: Record<string, unknown>
|
||||||
}>
|
}>
|
||||||
text?: string
|
text?: string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,10 @@ export interface Album {
|
||||||
trackCount?: number
|
trackCount?: number
|
||||||
recordLabel?: string
|
recordLabel?: string
|
||||||
copyright?: string
|
copyright?: string
|
||||||
editorialNotes?: any
|
editorialNotes?: {
|
||||||
|
short?: string
|
||||||
|
standard?: string
|
||||||
|
}
|
||||||
isComplete?: boolean
|
isComplete?: boolean
|
||||||
tracks?: Array<{
|
tracks?: Array<{
|
||||||
name: string
|
name: string
|
||||||
|
|
@ -51,7 +54,7 @@ export interface Album {
|
||||||
searchQuery?: string
|
searchQuery?: string
|
||||||
storefront?: string
|
storefront?: string
|
||||||
responseTime?: number
|
responseTime?: number
|
||||||
rawResponse?: any
|
rawResponse?: unknown
|
||||||
matchType?: 'exact' | 'fuzzy' | 'single'
|
matchType?: 'exact' | 'fuzzy' | 'single'
|
||||||
searchAttempts?: number
|
searchAttempts?: number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@ export interface ExifData {
|
||||||
location?: string
|
location?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ColorPalette {
|
||||||
|
hex?: string
|
||||||
|
rgb?: [number, number, number]
|
||||||
|
population?: number
|
||||||
|
}
|
||||||
|
|
||||||
export interface Photo {
|
export interface Photo {
|
||||||
id: string
|
id: string
|
||||||
src: string
|
src: string
|
||||||
|
|
@ -17,7 +23,7 @@ export interface Photo {
|
||||||
width: number
|
width: number
|
||||||
height: number
|
height: number
|
||||||
dominantColor?: string
|
dominantColor?: string
|
||||||
colors?: any
|
colors?: ColorPalette[]
|
||||||
aspectRatio?: number
|
aspectRatio?: number
|
||||||
exif?: ExifData
|
exif?: ExifData
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { EditorData } from './editor'
|
||||||
|
|
||||||
export type ProjectStatus = 'draft' | 'published' | 'list-only' | 'password-protected'
|
export type ProjectStatus = 'draft' | 'published' | 'list-only' | 'password-protected'
|
||||||
export type ProjectType = 'work' | 'labs'
|
export type ProjectType = 'work' | 'labs'
|
||||||
|
|
||||||
|
|
@ -13,7 +15,7 @@ export interface Project {
|
||||||
featuredImage: string | null
|
featuredImage: string | null
|
||||||
logoUrl: string | null
|
logoUrl: string | null
|
||||||
externalUrl: string | null
|
externalUrl: string | null
|
||||||
caseStudyContent: any | null
|
caseStudyContent: EditorData | null
|
||||||
backgroundColor: string | null
|
backgroundColor: string | null
|
||||||
highlightColor: string | null
|
highlightColor: string | null
|
||||||
projectType: ProjectType
|
projectType: ProjectType
|
||||||
|
|
@ -43,7 +45,7 @@ export interface ProjectFormData {
|
||||||
logoUrl: string
|
logoUrl: string
|
||||||
status: ProjectStatus
|
status: ProjectStatus
|
||||||
password: string
|
password: string
|
||||||
caseStudyContent: any
|
caseStudyContent: EditorData
|
||||||
showFeaturedImageInHeader: boolean
|
showFeaturedImageInHeader: boolean
|
||||||
showBackgroundColorInHeader: boolean
|
showBackgroundColorInHeader: boolean
|
||||||
showLogoInHeader: boolean
|
showLogoInHeader: boolean
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue