Commit graph

4 commits

Author SHA1 Message Date
d72d32001e fix: Address critical issues in admin form refactor
Phase 1: Critical Type Fixes
- Fix useDraftRecovery type signature to accept () => string | null
  (was incorrectly typed as string | null)
- Add TResponse generic parameter to AutoSaveStore interface
- Update all call sites to use function for draftKey reactivity

Phase 2: Robustness Improvements
- Remove non-null assertions in useFormGuards
- Capture autoSave in closures to prevent potential null access
- Make useFormGuards generic to accept any AutoSaveStore types

Documentation & Code Quality
- Document AlbumForm autosave initialization order
- Add comments explaining void operator usage for reactivity
- Fix eslint error: prefix unused _TResponse with underscore

These fixes address the critical issues found in PR review:
1. Type mismatch causing TypeScript errors
2. Non-null assertions that could cause crashes
3. Missing documentation for complex initialization patterns
2025-11-24 08:03:43 -08:00
4782584a47 fix: replace any types in admin and utility files (11 errors)
Phase 1 Batch 8: Admin & Misc type safety improvements - PHASE 1 COMPLETE

Fixed 11 any-type errors across 7 files:

1. src/lib/admin/autoSave.svelte.ts (1 error)
   - Fixed catch block: e: unknown (line 98)

2. src/lib/admin/autoSave.ts (1 error)
   - Fixed catch block: e: unknown (line 85)

3. src/lib/admin/autoSaveLifecycle.ts (2 errors)
   - Fixed controller type: AutoSaveStore<unknown, unknown> (line 13)

4. src/lib/admin/api.ts (1 error)
   - Fixed body cast: body as FormData (line 61)

5. src/lib/server/api-utils.ts (3 errors)
   - Fixed jsonResponse data: unknown (line 5)
   - Fixed isValidStatus parameter: unknown (line 46)
   - Fixed isValidPostType parameter: unknown (line 54)

6. src/lib/stores/project-form.svelte.ts (1 error)
   - Fixed setField value: unknown (line 57)

7. src/lib/stores/toast.ts (2 errors)
   - Fixed error callback: error: unknown (line 70)
   - Fixed custom component: unknown (line 85)

Progress: 0 any-type errors remaining!
PHASE 1 TYPE SAFETY: COMPLETE (103 errors fixed)
2025-11-24 02:43:52 -08:00
Devin AI
018fc67b2c lint: remove unused imports, variables, and dead code (10 fixes)
Co-Authored-By: Justin Edmund <justin@jedmund.com>
2025-11-23 14:30:57 +00:00
0334d3a831 feat(admin): create Svelte 5 runes-based autosave store
Introduces createAutoSaveStore() using $state() for automatic reactivity.
New store provides cleaner API while maintaining backward compatibility.

Changes:
- New: src/lib/admin/autoSave.svelte.ts with createAutoSaveStore()
- Uses $state() for status and lastError (reactive getters)
- Export AutoSaveStore and AutoSaveStoreOptions types
- Add JSDoc with usage examples
- Update autoSaveLifecycle.ts to accept both old and new types
- Export AutoSaveController type from old file for compatibility

Old createAutoSaveController() remains unchanged for gradual migration.
Type checking passes with no new errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 07:58:20 -07:00