From f0052cad760a5a8637811c1925019ee43cc2e475 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Fri, 20 Feb 2026 00:09:00 -0800 Subject: [PATCH] fix: add explicit type annotations to activity service methods Added explicit return type annotations (SuggestionActivity[], LikeActivity[], CommentActivity[], AchievementActivity[]) to all private activity service methods. This ensures TypeScript properly narrows the discriminated union types based on the ActivityType enum values, resolving compilation errors where the type system couldn't infer the specific activity subtypes. Also added type annotation to the async map callback in getLikeActivities to ensure the returned Promise resolves to the correct LikeActivity type. Co-Authored-By: Claude Sonnet 4.5 --- api/src/app/services/activity.service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/api/src/app/services/activity.service.ts b/api/src/app/services/activity.service.ts index b1a8178..e4c546f 100644 --- a/api/src/app/services/activity.service.ts +++ b/api/src/app/services/activity.service.ts @@ -8,6 +8,10 @@ import type { Activity, ActivityFeedResponse, ActivityUser, + SuggestionActivity, + LikeActivity, + CommentActivity, + AchievementActivity, } from "@library/shared-types"; import { ACHIEVEMENTS, ActivityType } from "@library/shared-types"; import { prisma } from "../lib/prisma"; @@ -61,7 +65,7 @@ export class ActivityService { limit: number, offset: number, userId?: string - ) { + ): Promise { const where = userId ? { userId, user: { profilePublic: true, isBanned: false } } : { user: { profilePublic: true, isBanned: false } }; @@ -104,7 +108,7 @@ export class ActivityService { limit: number, offset: number, userId?: string - ) { + ): Promise { const where = userId ? { userId, user: { profilePublic: true, isBanned: false } } : { user: { profilePublic: true, isBanned: false } }; @@ -131,7 +135,7 @@ export class ActivityService { // For each like, fetch the entity title const likesWithTitles = await Promise.all( - likes.map(async (like) => { + likes.map(async (like): Promise => { const entityTitle = await this.getEntityTitle( like.entityType, like.entityId @@ -158,7 +162,7 @@ export class ActivityService { limit: number, offset: number, userId?: string - ) { + ): Promise { const where = userId ? { userId, user: { profilePublic: true, isBanned: false } } : { user: { profilePublic: true, isBanned: false } }; @@ -246,7 +250,7 @@ export class ActivityService { limit: number, offset: number, userId?: string - ) { + ): Promise { const where = userId ? { userId,