Skip to content

Commit 0737e2e

Browse files
authored
Merge pull request #227 from varya/typescript-plan
chore: plan how to move to typescript
2 parents d52bca8 + bc229aa commit 0737e2e

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

TODO.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,105 @@ This document outlines proposed technical improvements for the varya.github.com
4848
- **Benefits**: Better developer experience, fewer runtime errors
4949
- **Effort**: 2-4 hours initially, ongoing
5050

51+
#### Phase 1: Setup and Configuration (1 hour)
52+
1. Add TypeScript dependencies:
53+
```bash
54+
yarn add -D typescript @types/react @types/react-dom @types/node @types/jest @types/styled-components @types/grommet
55+
```
56+
2. Create `tsconfig.json` with Gatsby-specific settings
57+
3. Update ESLint config for TypeScript
58+
4. Add TypeScript plugin to Gatsby config
59+
60+
#### Phase 2: Type Definitions (2 hours)
61+
1. Create type definitions for common utilities:
62+
- `src/common/utils.d.ts` - Define types for utility functions
63+
- `src/common/reactUtils.d.ts` - Define types for React-specific utilities
64+
65+
2. Add type definitions for third-party modules:
66+
- Create `src/types/grommet.d.ts` for Grommet-specific types
67+
- Create `src/types/gatsby.d.ts` for Gatsby-specific types
68+
69+
#### Phase 3: Component Migration (Iterative, 30 mins per component)
70+
Migrate components in the following order based on dependencies:
71+
72+
1. Atomic Components (No internal dependencies):
73+
- `src/components/Link/Link.tsx`
74+
- `src/components/Logo/Logo.tsx`
75+
- `src/components/Avatar/Avatar.tsx`
76+
- `src/components/Image/Image.tsx`
77+
- `src/components/PureHtml/PureHtml.tsx`
78+
79+
2. Simple Composed Components:
80+
- `src/components/Menu/Menu.tsx`
81+
- `src/components/Header/Header.tsx`
82+
- `src/components/Footer/Footer.tsx`
83+
- `src/components/Hero/Hero.tsx`
84+
- `src/components/Comments/Comments.tsx`
85+
86+
3. Complex Components:
87+
- `src/components/Layout/Layout.tsx`
88+
- `src/components/Workshop/Workshop.tsx`
89+
- `src/components/PatternJourney/PatternJourney.tsx`
90+
91+
4. Template Components:
92+
- `src/templates/Page.tsx`
93+
- `src/templates/Post.tsx`
94+
- `src/templates/BlogIndex.tsx`
95+
- `src/templates/TagIndex.tsx`
96+
97+
#### Phase 4: Page Components (2 hours)
98+
1. Create types for page props and GraphQL data
99+
2. Migrate page components:
100+
- `src/pages/index.tsx`
101+
- `src/pages/blog.tsx`
102+
- `src/pages/contact.tsx`
103+
- Service pages in `src/pages/services/`
104+
105+
#### Phase 5: Build System Updates (1 hour)
106+
1. Update Gatsby config files to TypeScript:
107+
- `gatsby-config.mjs``gatsby-config.ts`
108+
- `gatsby-node.js``gatsby-node.ts`
109+
- `gatsby-browser.js``gatsby-browser.ts`
110+
111+
#### Migration Strategy for Each Component:
112+
1. Create `.tsx` file alongside existing `.js`
113+
2. Add Props interface:
114+
```typescript
115+
interface ComponentProps {
116+
// Define props
117+
}
118+
```
119+
3. Convert component to TypeScript:
120+
```typescript
121+
const Component: React.FC<ComponentProps> = ({ prop1, prop2 }) => {
122+
// Implementation
123+
}
124+
```
125+
4. Update imports in `index.js` to point to new `.tsx` file
126+
5. Remove old `.js` file once tested
127+
128+
#### Testing Strategy:
129+
1. Add Jest configuration for TypeScript
130+
2. Create test files with `.test.tsx` extension
131+
3. Add type checking to CI pipeline
132+
133+
#### Completion Criteria:
134+
- All `.js` files migrated to `.tsx`
135+
- No TypeScript errors or warnings
136+
- All tests passing
137+
- Build process successful
138+
- No runtime errors in development or production
139+
140+
#### Rollback Strategy:
141+
- Keep `.js` files until TypeScript version is verified
142+
- Use feature branches for each component migration
143+
- Test thoroughly before merging to develop
144+
145+
**Total Estimated Effort**:
146+
- Initial setup: 3 hours
147+
- Per-component migration: ~30 minutes each
148+
- Total: ~15-20 hours spread across multiple PRs
149+
51150
### 9. Add comprehensive testing setup
52151
- **Issue**: No testing framework configured
53152
- **Action**: Add Jest + React Testing Library for component tests

0 commit comments

Comments
 (0)