feat: React + TypeScript + Vite migration scaffold (Step 1)#245
feat: React + TypeScript + Vite migration scaffold (Step 1)#245devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…act migration - Initialize Vite project with react-ts template - Install react-router-dom and sass dependencies - Port type definitions from Angular classes to TypeScript interfaces: Story, Comment, User, Settings, PollResult - Create hackerNewsApi.ts with async fetch functions replacing HackerNewsAPIService (fetchFeed, fetchItem, fetchPollContent, fetchUser) - Create formatCommentCount.ts utility replacing CommentPipe - Create SettingsContext with React Context + useState, persisting to localStorage with prefers-color-scheme media query listener - Create Loader and ErrorMessage components ported from Angular - Exclude Angular src/app/ from TypeScript compilation and ESLint - All lint and build checks pass Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Original prompt from Eashan
|
🤖 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:
|
| @@ -0,0 +1,8 @@ | |||
| export interface User { | |||
| id: string; | |||
| crated_time: number; | |||
There was a problem hiding this comment.
🟡 Typo in User interface: crated_time should be created_time
The User interface defines a field crated_time which is a typo for created_time. The node-hnapi /user/:id endpoint returns created_time as the field name. Any future code that accesses user.crated_time will get undefined at runtime because the JSON response key is created_time, not crated_time. TypeScript won't catch this since res.json() returns any and is cast to User without validation.
Note: this typo was copied from the original Angular model at src/app/shared/models/user.ts:3, but since the new User type is the interface that all new React code will consume, it should be corrected now.
| crated_time: number; | |
| created_time: number; |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good catch — fixed. The original Angular model had this typo (crated_time), but since the API returns created_time, the new React interface should use the correct field name to avoid runtime undefined values.
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Summary
This is Step 1 of the Angular-to-React migration. It replaces the Angular build tooling with a Vite + React + TypeScript project and ports the foundational layer (types, API client, utilities, context, and shared components) into the new React architecture.
What's included:
react-tstemplatereact-router-dom,sasssrc/types/Story.ts,Comment.ts,User.ts,Settings.ts,PollResult.tssrc/api/hackerNewsApi.ts): Plain async functions (fetchFeed,fetchItem,fetchPollContent,fetchUser) using nativefetch, replacing the RxJS-basedHackerNewsAPIServicesrc/utils/formatCommentCount.ts): ReplacesCommentPipewith a plain functionsrc/context/SettingsContext.tsx+src/context/settingsContextValue.ts+src/hooks/useSettings.ts): React Context +useStatereplacingSettingsService, withlocalStoragepersistence andprefers-color-scheme: darkmedia query listenerLoader.tsxandErrorMessage.tsxported from Angular with their SCSS stylessrc/app/are preserved for reference and excluded from TypeScript compilation and ESLintBuild verification:
npm run buildpasses (tsc + vite build)npm run lintpasses (ESLint with react-hooks and react-refresh plugins)Review & Testing Checklist for Human
src/types/match the Angular models — especiallyStory.tswhich referencesCommentandPollResultsrc/api/hackerNewsApi.ts— confirm the API endpoint paths match the originalHackerNewsAPIServiceSettingsContextlogic — confirm localStorage keys and default values match the originalSettingsServicenpm install && npm run buildlocally to confirm the project compiles cleanlysrc/app/Angular files are intact and untouched for use as reference in future migration stepsNotes
src/app/are kept intentionally — they will be removed in a later migration step once all components are ported.src/app/to avoid linting legacy Angular code.tsconfig.app.jsonexcludessrc/app/so Angular.tsfiles don't interfere with the Vite build.Link to Devin session: https://app.devin.ai/sessions/6eb01ada6ef6467981f60dbeba1c24ad
Requested by: @eashansinha
Devin Review