Skip to content

Support User-Defined KeyRegistry from Project Root for Type-Safe Overwatch UsageΒ #23

@karandeepsingh7070

Description

@karandeepsingh7070

Upcomming Feature : 1.1.9 - DX Improvement and Type Safety Ehnancement - [https://github.com//issues/20]

Upcoming, Overwatch uses an internal KeyRegistry to map shared state keys to their types for type-safe usage with useSharedState and usePicker. However, this approach does not scale when Overwatch is used as a distributed package since:

Branch to use - Dx-Typescript/Key-Registery

Imports inside node_modules cannot directly access user project files (keyRegistry.ts).

Relative imports break when expecting keyRegistry.ts at the project root.

  • Problem Statement
    We need a clean, scalable way for Overwatch to support a KeyRegistry defined by users in their project root while maintaining type safety, without breaking when installed via npm.

Goals

  • Allow users to define and maintain keyRegistry.ts in their projects.
  • Enable Overwatch to leverage this for type inference in useSharedState and usePicker.
  • Avoid forcing runtime overhead or breaking builds if the file is absent.
  • Keep zero-config for users if they do not wish to use type safety.

πŸ’‘ Potential Approaches

Paths Mapping in tsconfig.json

Require users to add:

"paths": {
  "overwatch-keyRegistry": ["./overwatch/keyRegistry.ts"]
}

and import:

import type { KeyRegistry } from "overwatch-keyRegistry";

βœ… Works reliably with TypeScript
❌ Requires manual user setup (DX tradeoff)


πŸ™Œ Feedback Requested

Please provide:
βœ… Your preferred approach
βœ… Any potential DX concerns
βœ… Questions or suggestions


Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions