refactor: unify section content types between types.ts and component-local definitions
- 主要语言
- TypeScript
- 星标
- 6
- 派生
- 15
- 平均合并
- 7 天 22 小时
- 30 天内合并 PR
- 2
描述
Section content types (ExperienceItem, EducationItem, and icon list items) are defined in two places with inconsistent fields, causing TypeScript incompatibilities.
```
types.ts (shared)
export interface ExperienceItem {
company: string;
title: string;
dates: string;
description: string[];
icon?: string; // string | undefined only
}
export interface EducationItem {
degree: string;
school: string;
year: string;
field_of_study?: string;
icon?: string; // string | undefined only
}
export interface IconListItem {
certification: string;
issuer: string;
date: string;
icon: string; // required, non-nullable
}
```
Component-local definitions
Each component defines its own version with extra fields:
ExperienceSection.tsx — local ExperienceItem:
- icon?: string | null (allows null)
- iconFile?: File | null (extra)
- iconBase64?: string | null (extra)
EducationSection.tsx — local EducationItem:
- icon?: string | null (allows null)
- iconFile?: File | null (extra)
- iconBase64?: string | null (extra)
IconListSection.tsx — local Certification:
- icon?: string | null (optional + nullable vs required)
- iconFile?: File | null (extra)
- iconBase64?: string | null (extra)
Impact
This type drift caused a build failure (TS2322) in SectionRenderer.tsx when the onUpdate callback was typed as Section['content']. The component-local types are not assignable to the types.ts union because of the null icon values and extra fields. Currently worked around with unknown typing in PR #245.
Proposed Solution
1. Update types.ts to be the single source of truth — add iconFile, iconBase64, and allow null on icon fields
2. Remove the duplicate local interfaces from ExperienceSection.tsx, EducationSection.tsx, and IconListSection.tsx — import from types.ts instead
3. Update SectionRenderer.tsx onUpdate callback type from unknown back to Section['content']
4. Verify all tests and build pass
Acceptance Criteria
- No duplicate type definitions for section content items
- All section content types imported from types.ts
- SectionRenderer.onUpdate uses Section['content'] (not unknown)
- npm run build passes
- npm test passes (all 1195+ tests)
Related
- PR #245 — build fix using unknown workaround
- PR #230 — Jules' SectionRenderer introduction (where the type mismatch originated)
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。