What problem does it solve?
When widening a function's return type to support new use cases or extensibility, developers often lose the narrow, precise return types that make TypeScript's type system valuable, leading to unnecessary type errors and reduced code safety for existing function calls.
Core Features & Use Cases
- Type-Safe Return Type Widening: Uses TypeScript overloads to preserve narrow return types for existing function calls while supporting widened return types for new use cases.
- Consistent Opt-In Pattern Integration: Follows existing project patterns for tool map constants, conditional agent registration, and feature flag gating to ensure seamless integration with existing codebases.
- Use Case: Ideal for OpenCode Swarm plugin development or any TypeScript codebase that uses opt-in tool registration and feature flags, where you need to expand function return types without breaking existing type safety for current users.
Quick Start
Ask the AI to apply the widen-return-type skill to update the return type of your existing tool registration function while keeping narrow return types intact for all current tool calls.