Skip to content

refactor: unify section content types between types.ts and component-local definitions #246

Description

@aafre

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions