refactor: Have ExperienceSection/EducationSection return full section object to avoid type assertions
- 主要语言
- TypeScript
- 星标
- 6
- 派生
- 15
- 平均合并
- 7 天 22 小时
- 30 天内合并 PR
- 2
描述
## Summary
In `EditorContent.tsx`, the `onUpdate` callbacks for `ExperienceSection` and `EducationSection` reconstruct the section object and use `as Section` type assertions:
```typescript
// Lines 319-378 in EditorContent.tsx
onUpdate={(updatedContent) => {
const updatedSection = {
...section,
content: updatedContent,
} as Section; // Type assertion bypasses safety checks
handleSectionUpdate(index, updatedSection);
}}
This pattern bypasses TypeScript's type safety checks.
Proposed Solution
Refactor child components (ExperienceSection, EducationSection) to:
1. Accept the full section object as a prop (not just content)
2. Return the entire updated section object in onUpdate
3. Eliminate the need for parent-side reconstruction and type assertions
Before
// Parent (EditorContent.tsx)
{
const updatedSection = { ...section, content: updatedContent } as Section;
handleSectionUpdate(index, updatedSection);
}}
/>
After
// Parent (EditorContent.tsx)
{
handleSectionUpdate(index, updatedSection);
}}
/>
Files to Update
- src/components/editor/EditorContent.tsx
- src/components/ExperienceSection.tsx
- src/components/EducationSection.tsx
- Related test files
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。