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 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 00:09:00 -08:00
parent 7f255afce6
commit f0052cad76
+9 -5
View File
@@ -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<SuggestionActivity[]> {
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<LikeActivity[]> {
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<LikeActivity> => {
const entityTitle = await this.getEntityTitle(
like.entityType,
like.entityId
@@ -158,7 +162,7 @@ export class ActivityService {
limit: number,
offset: number,
userId?: string
) {
): Promise<CommentActivity[]> {
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<AchievementActivity[]> {
const where = userId
? {
userId,