chore(angular-react): Migrate Comment model to React#255
chore(angular-react): Migrate Comment model to React#255devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| level: number; | ||
| user: string; | ||
| time: number; | ||
| timeAgo: string; |
There was a problem hiding this comment.
🔴 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.
| timeAgo: string; | |
| time_ago: string; |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
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_ago → timeAgo rename is intentional.
When this interface is consumed, a mapping/transformation layer (e.g., during API response deserialization) would handle the time_ago → timeAgo 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.
Summary
Migrates the Angular
Commentclass (src/app/shared/models/comment.ts) to a React-compatible TypeScript interface atsrc/models/comment.ts.Changes:
class→interface(no runtime behavior to preserve)time_ago→timeAgo(camelCase convention)comments: Comment[]fieldReview & Testing Checklist for Human
id,level,user,time,timeAgo,content,deleted,comments)time_ago→timeAgorename is acceptable for downstream consumerssrc/models/comment.tsthat would breakNotes
src/app/shared/models/comment.tsis intentionally not removed per playbook guidelines.tsc --noEmitcould not be run locally. The interface is syntactically trivial and correct.Link to Devin session: https://app.devin.ai/sessions/3763892c4f2f41a8ad0f7c36c99dc99a
Requested by: @charityquinn-cognition
Devin Review