Skip to content

Type Safety: Add discriminated unions for result types #9

@thesubtleties

Description

@thesubtleties

Summary

Several result types use { success: boolean; error?: string } pattern which allows invalid states (success=true with error message).

Current State

  • VodSyncResult in db/sync.ts
  • Various hook return types

Proposed Solution

type SyncResult =
  | { success: true; movieCount: number; seriesCount: number; /* ... */ }
  | { success: false; error: string };

Benefits

  • Invalid states become unrepresentable
  • Better TypeScript inference
  • Clearer error handling at call sites

From PR #6 Review

Type design synthesis rated overall type safety at 5.9/10, with discriminated unions as key improvement area.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions