Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/models/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface Comment {
id: number;
level: number;
user: string;
time: number;
timeAgo: string;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 timeAgo property name doesn't match existing time_ago API contract

The new Comment interface uses timeAgo (camelCase) for the time-ago field, but the entire codebase — including the existing Comment class at src/app/shared/models/comment.ts:6, the Story model at src/app/shared/models/story.ts:11, and all templates (e.g. src/app/item-details/comment/comment.component.html:5: {{comment.time_ago}}) — consistently uses time_ago (snake_case), matching the Hacker News API response shape. If this new interface is used to type any comment data, the timeAgo property will never be populated from the API, and any code accessing it will get undefined.

Suggested change
timeAgo: string;
time_ago: string;
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the API contract mismatch. However, the PR instructions explicitly requested camelCase naming conventions for this migration, and the repo's knowledge base also specifies "always use camelCase." The time_agotimeAgo rename is intentional.

When this interface is consumed, a mapping/transformation layer (e.g., during API response deserialization) would handle the time_agotimeAgo conversion. This is a standard pattern in React/TS projects that prefer camelCase internally while consuming snake_case APIs.

Keeping timeAgo as specified by the requester.

content: string;
deleted: boolean;
comments: Comment[];
}