From 6dcc517cc6372c786794a6e4919bd2161e357c96 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 29 Nov 2025 02:22:03 -0800 Subject: [PATCH] chore: remove obsolete planning documents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove outdated planning and session prompt files that are no longer needed after completing the TanStack Query migration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CLEANUP_PLAN.md | 147 ---------------- NEXT_SESSION_PROMPT.md | 116 ------------- TYPESCRIPT_IMPROVEMENTS.md | 341 ------------------------------------- 3 files changed, 604 deletions(-) delete mode 100644 CLEANUP_PLAN.md delete mode 100644 NEXT_SESSION_PROMPT.md delete mode 100644 TYPESCRIPT_IMPROVEMENTS.md diff --git a/CLEANUP_PLAN.md b/CLEANUP_PLAN.md deleted file mode 100644 index ebac2dcf..00000000 --- a/CLEANUP_PLAN.md +++ /dev/null @@ -1,147 +0,0 @@ -# Svelte-Main Branch Cleanup Plan - -## Overview -This document outlines the remaining work needed to clean up the `svelte-main` branch and get the build green. - -## Completed Fixes - -### 1. Environment/Generated Module Issues -- Ran Paraglide codegen to generate translation files in `src/lib/paraglide/` -- Added type declarations for `$env/static/public` module in `src/lib/types/declarations.d.ts` - -### 2. Broken Imports from Removed Legacy API Layer -- Updated `SearchSidebar.svelte` to use new adapter layer -- Updated `Party.svelte` to use new adapter layer -- Updated `teams/new/+page.svelte` to use new adapter layer - -### 3. Type Shims for External Libraries -- Added comprehensive type declarations for `wx-svelte-grid` in `src/lib/types/declarations.d.ts` - -### 4. RequestOptions Cache Type Incompatibility -- Fixed `RequestOptions` interface in `src/lib/api/adapters/types.ts` to exclude 'cache' from RequestInit extension -- Added both `cacheTime?: number` and `cache?: RequestCache` properties -- Updated `base.adapter.ts` to use `cacheTime` instead of `cache` for duration - -### 5. Users Resource Module -- Updated `src/lib/api/resources/users.ts` to use `userAdapter` instead of removed `../core` module -- Changed function signature from `update(fetch, userId, params)` to `update(userId, params)` - -### 6. UserSettingsModal.svelte Fixes -- Fixed Switch import path (case sensitivity: `switch.svelte` -> `Switch.svelte`) -- Fixed `users.update` call signature -- Removed invalid footer snippet definition -- Removed unused `Snippet` import - -### 7. Character Type in Entity Adapter -- Added missing properties to Character type in `entity.adapter.ts`: - - `gender?: number` - - `proficiency?: number[]` - - `race?: number[]` - - `hp?: { minHp, maxHp, maxHpFlb }` - - `atk?: { minAtk, maxAtk, maxAtkFlb }` - - `uncap?: { flb, ulb, transcendence }` - -### 8. Adapters Index File -- Created `src/lib/api/adapters/index.ts` to export all adapters and types - -### 9. Character Type in Entities -- Added missing properties to Character type in `src/lib/types/api/entities.ts`: - - `gender`, `race`, `proficiency`, `hp`, `atk` - -## Remaining Type Errors (~378 errors) - -### High Priority (Most Impactful) - -#### 1. 'firstItem' and 'item' Possibly Undefined (27 errors) -- **Location**: `src/routes/teams/new/+page.svelte` -- **Issue**: TypeScript strict null checks flagging array access without null guards -- **Fix**: Add null checks before accessing `items[0]` and in forEach loops - -#### 2. PartyCtx Missing openPicker Property (8 errors) -- **Location**: Various components using party context -- **Issue**: `PartyCtx` type doesn't include `openPicker` method -- **Fix**: Update `PartyCtx` type definition to include `openPicker` method - -#### 3. Missing Paraglide Translation Keys (18 errors) -- **Keys**: `context_view_details`, `context_replace`, `context_remove` -- **Location**: `src/lib/paraglide/messages` -- **Fix**: Add missing translation keys to `project.inlang/messages/en.json` and `ja.json` - -#### 4. Summon/Weapon Missing hp/atk Properties (18 errors) -- **Location**: Entity adapter types -- **Issue**: Summon and Weapon types in `entity.adapter.ts` need hp/atk properties -- **Fix**: Update Summon type to include `hp` and `atk` nested objects - -### Medium Priority - -#### 5. exactOptionalPropertyTypes Violations (~15 errors) -- **Issue**: Props with `undefined` values being passed to components that don't accept undefined -- **Fix**: Update component Props interfaces to accept `undefined` for optional properties - -#### 6. Select.svelte ItemIndicator Errors (4 errors) -- **Issue**: `Select.ItemIndicator` doesn't exist in bits-ui -- **Fix**: Check bits-ui documentation for correct component name or remove usage - -#### 7. Button.svelte Icon Type Issues (2 errors) -- **Issue**: `icon` prop is `string | undefined` but Icon component expects `string` -- **Fix**: Add conditional rendering or default value for icon prop - -#### 8. DropdownItem.svelte asChild Issue (2 errors) -- **Issue**: `asChild` prop doesn't exist on DropdownMenu.Item in bits-ui -- **Fix**: Use `child` snippet pattern instead of `asChild` prop - -### Lower Priority - -#### 9. maxLength vs maxlength (4 errors) -- **Issue**: HTML attribute should be lowercase `maxlength` -- **Fix**: Change `maxLength` to `maxlength` in input elements - -#### 10. Button Variant "outlined" (3 errors) -- **Issue**: "outlined" is not a valid Button variant -- **Fix**: Use correct variant name (check Button component for valid variants) - -#### 11. SearchResult Type Mismatch (5 errors) -- **Issue**: `SearchResult[]` vs `SearchResult[]` type mismatch -- **Fix**: Update function signatures to use consistent SearchResult type - -## Files Modified in This Session - -1. `src/lib/api/adapters/types.ts` - RequestOptions cache fix -2. `src/lib/api/adapters/base.adapter.ts` - cacheTime usage -3. `src/lib/api/adapters/entity.adapter.ts` - Character type properties -4. `src/lib/api/adapters/index.ts` - New file for exports -5. `src/lib/api/resources/users.ts` - Updated to use userAdapter -6. `src/lib/types/declarations.d.ts` - wx-svelte-grid and $env type shims -7. `src/lib/types/api/entities.ts` - Character type properties -8. `src/lib/components/UserSettingsModal.svelte` - Multiple fixes -9. `src/lib/components/panels/SearchSidebar.svelte` - Accepted upstream version -10. `src/lib/components/party/Party.svelte` - granblueId fix -11. `src/routes/teams/new/+page.svelte` - Accepted upstream version - -## Commands to Verify Progress - -```bash -# Count remaining errors -pnpm check 2>&1 | grep -c "Error:" - -# Analyze error patterns -pnpm check 2>&1 | grep "Error:" | sort | uniq -c | sort -rn | head -20 - -# Run lint -pnpm lint - -# Run build -pnpm build -``` - -## Next Steps - -1. Fix the 'firstItem'/'item' possibly undefined errors in teams/new/+page.svelte -2. Add missing Paraglide translation keys -3. Update PartyCtx type to include openPicker -4. Update Summon type in entity.adapter.ts to include hp/atk -5. Fix exactOptionalPropertyTypes violations -6. Fix bits-ui component usage (Select.ItemIndicator, DropdownItem asChild) -7. Run `pnpm check` to verify all errors are resolved -8. Run `pnpm lint` and `pnpm build` -9. Create PR with all fixes diff --git a/NEXT_SESSION_PROMPT.md b/NEXT_SESSION_PROMPT.md deleted file mode 100644 index 81ed322e..00000000 --- a/NEXT_SESSION_PROMPT.md +++ /dev/null @@ -1,116 +0,0 @@ -# Prompt for Next Devin Session - -## Task -Continue cleaning up type errors in the `svelte-main` branch of `jedmund/hensei-web`. The goal is to get the build green by fixing all remaining type errors. - -## Context -This is a Svelte 5 rewrite of a Granblue Fantasy team composition app. The previous sessions reduced type errors from ~412 to ~161. A detailed plan of completed and remaining work is in `CLEANUP_PLAN.md`. - -## Starting Point -1. Checkout the `svelte-main` branch in `/home/ubuntu/repos/hensei-web` -2. Run `pnpm check 2>&1 | grep -c "Error:"` to see current error count (~161) -3. Review this file for detailed context on what's been fixed and what remains - -## Completed Fixes (This Session - 219 -> 161 errors) -- Fixed teams/new/+page.svelte position type assertions (non-null assertions for array access after length check) -- Fixed Party.svelte editKey type (string | null -> string | undefined) -- Fixed sidebar.svelte.ts Component type to accept any props (Component) -- Fixed database/characters/[id]/+page.svelte UncapData type (provide default values for flb/ulb) -- Fixed DetailScaffold.svelte optional props (use nullish coalescing for optional callbacks) -- Fixed SearchSidebar.svelte params construction (conditionally add properties instead of passing undefined) -- Fixed SearchSidebar.svelte granblue_id -> granblueId property name -- Fixed Party.svelte mainWeapon derived state (removed arrow function wrapper) - -## Remaining Type Errors to Fix (~161 errors) - -### Files with Most Errors -1. Party.svelte - 22 errors -2. database/characters/[id]/+page.svelte - 19 errors -3. Checkbox.svelte - 19 errors -4. SearchSidebar.svelte - 12 errors -5. teams/new/+page.svelte - 10 errors -6. test/images/+page.svelte - 9 errors -7. Switch.svelte - 9 errors -8. StatsSection.svelte - 9 errors -9. Button.svelte - 8 errors -10. WeaponUnit.svelte - 7 errors - -### High Priority Error Patterns - -1. **SearchResult type mismatch** (5 errors) - - Issue: `(items: SearchResult[]) => Promise` not assignable to `(items: SearchResult[]) => void` - - Files: Party.svelte, teams/new/+page.svelte, SearchSidebar.svelte - - Fix: Update function signatures or SearchResult type definition - -2. **Object is possibly 'undefined'** (5 errors) - - Various files need null guards or optional chaining - -3. **number | null vs number | undefined** (4 errors) - - File: ItemHeader.svelte - - Fix: Normalize null/undefined handling (use ?? operator) - -4. **Expected 1 arguments, but got 2** (4 errors) - - Function call signature mismatches - -5. **Conversion of number to "0" | "1" | "2" | "3"** (3 errors) - - File: Party.svelte (job skill slot handling) - - Fix: Use `as unknown as "0" | "1" | "2" | "3"` or update type definitions - -### Medium Priority Error Patterns - -6. **exactOptionalPropertyTypes violations** (multiple errors) - - Issue: Passing `undefined` explicitly to optional props - - Fix: Use nullish coalescing or omit the property entirely - -7. **Select.Item disabled prop** (2 errors) - - bits-ui type compatibility issue - -8. **RadioGroup.Item type mismatch** (2 errors) - - bits-ui type compatibility issue - -9. **Property 'normalizer' does not exist on DatabaseProvider** (2 errors) - -10. **Module has no exported member 'PartyView'** (2 errors) - - File: party schema - - Fix: Add or update the export - -### Lower Priority - -11. **Argument of type '"01"' not assignable to ImageVariant** (2 errors) -12. **'uncapLevel' is possibly 'null'** (2 errors) -13. **'to' is possibly 'null'** (2 errors) -14. **Expression produces union type too complex** (3 errors) -15. **Parameter implicitly has 'any' type** (6 errors) - -## Commands Reference -```bash -# Check error count -pnpm check 2>&1 | grep -c "Error:" - -# Analyze error patterns -pnpm check 2>&1 | grep "Error:" | sort | uniq -c | sort -rn | head -20 - -# Find specific errors -pnpm check 2>&1 | grep -B2 "specific error text" - -# Run lint -pnpm lint - -# Run build -pnpm build - -# Regenerate Paraglide translations -pnpm paraglide-js compile --project ./project.inlang -``` - -## Important Notes -- This project uses `exactOptionalPropertyTypes: true` in tsconfig, which is stricter than normal TypeScript -- The codebase uses Svelte 5 runes (`$state`, `$derived`, `$effect`) -- bits-ui v2.9.6 is used for UI components - check their docs for correct API -- Focus on errors only, not warnings (per user instruction) -- The branch `devin/1764361948-fix-type-errors` contains the latest fixes - merge into svelte-main or continue from there - -## Success Criteria -- `pnpm check` returns 0 errors -- `pnpm lint` passes -- `pnpm build` succeeds diff --git a/TYPESCRIPT_IMPROVEMENTS.md b/TYPESCRIPT_IMPROVEMENTS.md deleted file mode 100644 index 4ba11a94..00000000 --- a/TYPESCRIPT_IMPROVEMENTS.md +++ /dev/null @@ -1,341 +0,0 @@ -# TypeScript Quality Improvement Plan - -**Status:** 0 TypeScript errors achieved (151 → 0) -**Next Phase:** Code quality and maintainability improvements - -## Overview - -While we've eliminated all TypeScript errors, several opportunities exist to improve type safety, reduce workarounds, and enhance maintainability. - ---- - -## Phase 1: Critical Type Safety (High Priority) - -### 1.1 Remove Type Assertions in Component Props - -**Problem:** Using `as any` to spread props loses type safety - -**Files:** -- `src/lib/components/uncap/UncapIndicator.svelte` (lines 167, 169) -- `src/lib/components/ui/segmented-control/SegmentedControl.svelte` (line 88) - -**Tasks:** -- [ ] Create proper union type for StarRender props -- [ ] Define TranscendenceStarProps and UncapStarProps interfaces -- [ ] Replace `{...(star.props as any)}` with properly typed spread -- [ ] Create typed wrapper for RadioGroupPrimitive or fix optionalProps spreading - -**Acceptance Criteria:** -- No `as any` casts in component prop spreading -- Full IntelliSense support for star component props -- Type errors caught at compile time - -**Effort:** Medium (4-6 hours) - -### 1.2 Unify Visibility Types - -**Problem:** Number/string mismatch between frontend and API requiring runtime conversion - -**Files:** -- `src/lib/types/api/party.ts` (visibility: number) -- `src/lib/api/adapters/party.adapter.ts` (visibility: string literal) -- `src/lib/services/party.service.ts` (runtime mapping) - -**Tasks:** -- [ ] Create PartyVisibility enum/const -- [ ] Update Party type to use string literals -- [ ] Remove number-to-string mapping in party.service.ts -- [ ] Update all visibility references across codebase -- [ ] Update API serialization if needed - -**Acceptance Criteria:** -- Single source of truth for visibility values -- No runtime type conversion needed -- Type safety when setting visibility - -**Effort:** Medium (3-4 hours) - -**Impact:** Prevents invalid visibility values at compile time - ---- - -## Phase 2: Third-Party Library Improvements (Medium Priority) - -### 2.1 Create bits-ui Wrapper Components - -**Problem:** Using `optionalProps()` workaround for type incompatibilities - -**Files:** -- `src/lib/components/ui/Select.svelte` -- `src/lib/components/ui/segmented-control/SegmentedControl.svelte` -- `src/lib/components/ui/RadioGroup.svelte` (if exists) - -**Tasks:** -- [ ] Create `src/lib/components/ui/bits-ui-wrappers/` directory -- [ ] Create SelectRoot wrapper with explicit prop typing -- [ ] Create RadioGroupRoot wrapper with explicit prop typing -- [ ] Update consuming components to use wrappers -- [ ] Document why wrappers exist (bits-ui type issues) - -**Acceptance Criteria:** -- No `optionalProps()` calls for bits-ui components -- Clear prop types for each wrapper -- Wrappers forward only supported props - -**Effort:** Medium (4-5 hours) - -### 2.2 Add wx-svelte-grid Type Definitions - -**Problem:** Missing Cell export causing workaround with loose types - -**Files:** -- `src/lib/components/database/cells/LastUpdatedCell.svelte` -- Other cell components using wx-svelte-grid - -**Tasks:** -- [ ] Create `src/lib/types/wx-svelte-grid.d.ts` -- [ ] Define Cell, Grid, and other used types -- [ ] Replace `[key: string]: any` with proper Cell interface -- [ ] Update all cell components to use typed Cell props - -**Acceptance Criteria:** -- Proper Cell type available for import -- No `[key: string]: any` in cell components -- IntelliSense support for grid props - -**Effort:** Small (2-3 hours) - ---- - -## Phase 3: Type Consolidation (Medium Priority) - -### 3.1 Consolidate Awakening Types - -**Problem:** Two different Awakening interfaces exist - -**Files:** -- `src/lib/types/Awakening.d.ts` -- `src/lib/types/api/entities.ts` - -**Tasks:** -- [ ] Compare both definitions and identify differences -- [ ] Choose canonical location (prefer entities.ts) -- [ ] Remove duplicate definition -- [ ] Update all imports to use single source -- [ ] Ensure LocalizedName is properly defined - -**Acceptance Criteria:** -- Single Awakening type definition -- All imports use same source -- No breaking changes to existing code - -**Effort:** Small (1-2 hours) - -### 3.2 Type the `any` Usages - -**Problem:** Loose typing in services and adapters - -**Files to audit:** -```bash -grep -r ": any" src/lib --include="*.ts" --include="*.svelte" -``` - -**Common patterns to fix:** -- `row: any` → `row: DatabaseRow` (or specific entity type) -- `item: any` → `item: GridItem` -- `mapped: any` → `mapped: CreatePartyParams` -- `result: any` → proper return type -- Context types using `any` - -**Tasks:** -- [ ] Audit all `any` usages and categorize -- [ ] Create proper types for common patterns (DatabaseRow, GridItem, etc.) -- [ ] Replace `any` with specific types -- [ ] Add generics where appropriate - -**Acceptance Criteria:** -- Minimal `any` usage (only where truly necessary) -- Clear justification comment for remaining `any` usages -- Improved IntelliSense throughout codebase - -**Effort:** Large (6-8 hours) - ---- - -## Phase 4: Test Infrastructure (Low Priority) - -### 4.1 Create Test Mock Factories - -**Problem:** Test mocks are brittle and require manual updates when types change - -**Files:** -- `src/lib/api/adapters/__tests__/entity.adapter.test.ts` -- `src/lib/api/adapters/__tests__/grid.adapter.test.ts` -- Other test files - -**Tasks:** -- [ ] Create `src/lib/testing/factories.ts` -- [ ] Implement `createMockWeapon(overrides?)` -- [ ] Implement `createMockCharacter(overrides?)` -- [ ] Implement `createMockSummon(overrides?)` -- [ ] Implement `createMockParty(overrides?)` -- [ ] Update all tests to use factories -- [ ] Add JSDoc examples for each factory - -**Acceptance Criteria:** -- All test mocks use factory functions -- Overrides supported for customization -- Type-safe mock creation -- Tests resilient to type changes - -**Effort:** Medium (4-5 hours) - -### 4.2 Improve Test Coverage for Type Transformations - -**Focus areas:** -- Visibility mapping (number → string) -- Awakening type handling -- Party payload transformations -- Grid item CRUD operations - -**Tasks:** -- [ ] Add tests for mapToApiPayload visibility conversion -- [ ] Add tests for awakening null/undefined handling -- [ ] Test edge cases in type transformations -- [ ] Document expected type contracts in tests - -**Effort:** Medium (3-4 hours) - ---- - -## Phase 5: Code Quality (Low Priority) - -### 5.1 Address TypeScript Warnings - -**Current status:** 190 warnings - -**Categories to review:** -- Unused CSS selectors -- Non-reactive updates -- Accessibility warnings -- Import warnings - -**Tasks:** -- [ ] Run `pnpm check 2>&1 | grep "Warn:" | sort | uniq -c` -- [ ] Categorize warnings by type and severity -- [ ] Fix or suppress unused CSS warnings -- [ ] Review non-reactive update warnings (may indicate bugs) -- [ ] Address accessibility issues - -**Acceptance Criteria:** -- Warnings reduced by 50% or more -- All critical warnings addressed -- Suppressions documented with reason - -**Effort:** Medium (4-6 hours) - -### 5.2 Add JSDoc Documentation - -**Problem:** Complex type transformations lack explanation - -**Target areas:** -- `mapToApiPayload()` in party.service.ts -- Visibility mapping logic -- Type assertion workarounds -- Third-party wrapper purposes - -**Tasks:** -- [ ] Document visibility mapping with TODO for unification -- [ ] Explain why type assertions are needed -- [ ] Add examples to complex type transformations -- [ ] Document third-party library workarounds - -**Acceptance Criteria:** -- All workarounds have explanation comments -- Complex transformations documented -- TODOs added for future improvements - -**Effort:** Small (2-3 hours) - -### 5.3 Strict Null Checks Review - -**Problem:** Some null handling is implicit or unclear - -**Tasks:** -- [ ] Review null coalescing operators (`??`) -- [ ] Document what empty string defaults mean -- [ ] Consider making related properties required together (e.g., avatar.picture + avatar.element) -- [ ] Add validation for undefined vs null semantics - -**Effort:** Small (2-3 hours) - ---- - -## Implementation Strategy - -### Recommended Order: - -**Week 1: Critical Type Safety** -1. Remove type assertions in UncapIndicator (1.1) -2. Unify visibility types (1.2) - -**Week 2: Third-Party Libraries** -3. Create bits-ui wrappers (2.1) -4. Add wx-svelte-grid types (2.2) - -**Week 3: Type Consolidation** -5. Consolidate Awakening types (3.1) -6. Type the `any` usages (3.2) - ongoing - -**Week 4: Polish** -7. Create test factories (4.1) -8. Address warnings (5.1) -9. Add JSDoc (5.2) - -### Success Metrics: - -- **Type Safety:** 0 `as any` casts (except documented cases) -- **Consistency:** Single source of truth for shared types -- **Maintainability:** Test factories, JSDoc, reduced warnings -- **Developer Experience:** Better IntelliSense, clearer errors - -### Non-Goals: - -- Perfect type coverage (pragmatic > perfect) -- Rewriting working code just for types -- Over-engineering simple components - ---- - -## Notes - -### Philosophy: -- Incremental improvement over big rewrites -- Document "why" for workarounds -- Type safety where it adds value -- Pragmatic trade-offs are okay - -### When to Use `any`: -- Truly dynamic data (rare) -- Third-party library gaps (with comment) -- Overly complex generic inference -- Always add `// eslint-disable-next-line @typescript-eslint/no-explicit-any` and justification - -### When to Create Wrappers: -- Type incompatibilities we can't fix upstream -- Need to restrict API surface -- Want better defaults -- Shared configuration across usages - ---- - -## Progress Tracking - -- [ ] Phase 1: Critical Type Safety (0/2) -- [ ] Phase 2: Third-Party Libraries (0/2) -- [ ] Phase 3: Type Consolidation (0/2) -- [ ] Phase 4: Test Infrastructure (0/2) -- [ ] Phase 5: Code Quality (0/3) - -**Last Updated:** 2025-11-28 -**Current Status:** Planning phase