Description
Currently, when using useSharedState and usePicker, the inferred types are limited, and developers need to explicitly specify the generic type even if the shared state is already typed. This adds unnecessary boilerplate for developers and makes the DX less clean.
Example:
const [user, setUser] = useSharedState<User>('user');
// or
const userName = usePicker<User, string>('user', user => user.name);
Ideally, the type should be inferred from the store itself so users do not have to re-specify the type repeatedly.
Proposal
- Allow
useSharedState and usePicker to automatically infer types from the registered shared state key.
- Support optional user-defined generic override if needed, but keep it ergonomic for most use cases.
Benefits
✅ Reduces boilerplate for consumers
✅ Improves DX and type-safety without redundancy
✅ Makes Overwatch APIs feel more modern and aligned with TypeScript best practices
Tasks
Description
Currently, when using
useSharedStateandusePicker, the inferred types are limited, and developers need to explicitly specify the generic type even if the shared state is already typed. This adds unnecessary boilerplate for developers and makes the DX less clean.Example:
Ideally, the type should be inferred from the store itself so users do not have to re-specify the type repeatedly.
Proposal
useSharedStateandusePickerto automatically infer types from the registered shared state key.Benefits
✅ Reduces boilerplate for consumers
✅ Improves DX and type-safety without redundancy
✅ Makes
OverwatchAPIs feel more modern and aligned with TypeScript best practicesTasks
useSharedStateto infer type based on the keyusePickerto infer state type based on the key