Skip to content

Commit 797ec15

Browse files
committed
fix: resolve TypeScript compilation errors and update tests
- Add extends object constraint to makeRequest generic for 'in' operator - Fix artist.name type errors by casting to any when using .name fallback - Fix mock cache object type casting and parameter types - Update test to expect 202 Accepted (not 204) for notifications per MCP spec All TypeScript errors resolved. Ready for CI/CD deployment.
1 parent ff386c7 commit 797ec15

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/clients/lastfm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export class LastfmClient {
391391
/**
392392
* Make a request to the Last.fm API
393393
*/
394-
private async makeRequest<T>(params: Record<string, string>): Promise<T> {
394+
private async makeRequest<T extends object>(params: Record<string, string>): Promise<T> {
395395
const searchParams = new URLSearchParams({
396396
api_key: this.apiKey,
397397
format: 'json',

src/protocol/handlers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ Your authentication will be secure and connection-specific - only you will have
696696
text: `🎵 **Track Information**
697697
698698
**Track:** ${data.track.name}
699-
**Artist:** ${data.track.artist.name}
699+
**Artist:** ${data.track.artist['#text'] || (data.track.artist as any).name}
700700
**Album:** ${data.track.album?.['#text'] || 'Unknown'}
701701
702702
**Stats:**
@@ -867,7 +867,7 @@ ${artistList}`,
867867
const trackList = tracks
868868
.map((t) => {
869869
const album = t.album?.['#text'] ? ` [${t.album['#text']}]` : ''
870-
return `• ${t.artist.name} - ${t.name}${album} (${Math.round(parseFloat(t.match) * 100)}% match)`
870+
return `• ${t.artist['#text'] || (t.artist as any).name} - ${t.name}${album} (${Math.round(parseFloat(t.match) * 100)}% match)`
871871
})
872872
.join('\n')
873873

@@ -1084,7 +1084,7 @@ Total albums: ${data.topalbums['@attr'].total}`,
10841084
const trackList = tracks
10851085
.map((track) => {
10861086
const album = track.album?.['#text'] ? ` [${track.album['#text']}]` : ''
1087-
return `• ${track.artist.name} - ${track.name}${album}`
1087+
return `• ${track.artist['#text'] || (track.artist as any).name} - ${track.name}${album}`
10881088
})
10891089
.join('\n')
10901090

@@ -1128,7 +1128,7 @@ Total loved tracks: ${data.lovedtracks['@attr'].total}`,
11281128
text: `🎵 **Track Information**
11291129
11301130
**Track:** ${data.track.name}${loved}
1131-
**Artist:** ${data.track.artist.name}
1131+
**Artist:** ${data.track.artist['#text'] || (data.track.artist as any).name}
11321132
**Album:** ${data.track.album?.['#text'] || 'Unknown'}
11331133
11341134
**Stats:**
@@ -1305,7 +1305,7 @@ ${artistList}`,
13051305
const trackList = tracks
13061306
.map((t) => {
13071307
const album = t.album?.['#text'] ? ` [${t.album['#text']}]` : ''
1308-
return `• ${t.artist.name} - ${t.name}${album} (${Math.round(parseFloat(t.match) * 100)}% match)`
1308+
return `• ${t.artist['#text'] || (t.artist as any).name} - ${t.name}${album} (${Math.round(parseFloat(t.match) * 100)}% match)`
13091309
})
13101310
.join('\n')
13111311

src/utils/cache.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,25 +355,25 @@ export function createLastfmCache(kv?: KVNamespace): SmartCache {
355355
async get() {
356356
return null
357357
},
358-
async set() {
358+
async set(): Promise<void> {
359359
return
360360
},
361-
async getOrFetch(_type, _key, fetcher) {
361+
async getOrFetch<T>(_type: keyof CacheConfig, _key: string, fetcher: () => Promise<T>): Promise<T> {
362362
return fetcher()
363363
},
364-
async invalidate() {
364+
async invalidate(): Promise<void> {
365365
return
366366
},
367-
async invalidatePattern() {
367+
async invalidatePattern(): Promise<void> {
368368
return
369369
},
370-
async getStats() {
370+
getStats: async () => {
371371
return { totalEntries: 0, entriesByType: {}, pendingRequests: 0 }
372372
},
373373
cleanupPendingRequests() {
374374
return
375375
},
376-
} as SmartCache
376+
} as unknown as SmartCache
377377
}
378378

379379
return new SmartCache(kv, {

test/integration/mcp-client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,8 @@ describe('MCP Client Integration Tests', () => {
787787

788788
const response = await worker.fetch(request, mockEnv, {} as any)
789789

790-
// Notifications should return 204 with no body
791-
expect(response.status).toBe(204)
790+
// Notifications should return 202 Accepted per MCP spec
791+
expect(response.status).toBe(202)
792792
const text = await response.text()
793793
expect(text).toBe('') // Empty response for notifications
794794
})

0 commit comments

Comments
 (0)