fix: correct TypeScript types in ActivityService

Fixed two type errors:
- Changed ActivityType assertions from 'as ActivityType' to 'as const'
  for proper literal type inference
- Changed achievement.name to achievement.title to match the actual
  AchievementDefinition structure

This ensures type safety and proper union type discrimination.
This commit is contained in:
2026-02-20 00:02:11 -08:00
committed by Naomi Carrigan
parent b1aab70b44
commit 808df775a4
+5 -5
View File
@@ -89,7 +89,7 @@ export class ActivityService {
return suggestions.map((suggestion) => ({ return suggestions.map((suggestion) => ({
id: `suggestion-${suggestion.id}`, id: `suggestion-${suggestion.id}`,
type: "SUGGESTION" as ActivityType, type: "SUGGESTION" as const,
user: suggestion.user as ActivityUser, user: suggestion.user as ActivityUser,
entityType: suggestion.entityType, entityType: suggestion.entityType,
suggestionTitle: suggestion.title, suggestionTitle: suggestion.title,
@@ -139,7 +139,7 @@ export class ActivityService {
); );
return { return {
id: `like-${like.id}`, id: `like-${like.id}`,
type: "LIKE" as ActivityType, type: "LIKE" as const,
user: like.user as ActivityUser, user: like.user as ActivityUser,
entityType: like.entityType, entityType: like.entityType,
entityId: like.entityId, entityId: like.entityId,
@@ -229,7 +229,7 @@ export class ActivityService {
return { return {
id: `comment-${comment.id}`, id: `comment-${comment.id}`,
type: "COMMENT" as ActivityType, type: "COMMENT" as const,
user: comment.user as ActivityUser, user: comment.user as ActivityUser,
entityType, entityType,
entityId, entityId,
@@ -282,10 +282,10 @@ export class ActivityService {
const achievement = ACHIEVEMENTS[ua.achievementKey]; const achievement = ACHIEVEMENTS[ua.achievementKey];
return { return {
id: `achievement-${ua.id}`, id: `achievement-${ua.id}`,
type: "ACHIEVEMENT" as ActivityType, type: "ACHIEVEMENT" as const,
user: ua.user as ActivityUser, user: ua.user as ActivityUser,
achievementKey: ua.achievementKey, achievementKey: ua.achievementKey,
achievementName: achievement.name, achievementName: achievement.title,
achievementIcon: achievement.icon, achievementIcon: achievement.icon,
achievementPoints: achievement.points, achievementPoints: achievement.points,
createdAt: ua.earnedAt!, createdAt: ua.earnedAt!,