koa-proxies icon indicating copy to clipboard operation
koa-proxies copied to clipboard

feat(typescript): improve TS definitions for better context support

Open rilopez opened this issue 5 months ago • 0 comments

This pull request introduces improvements to the TypeScript type definitions for koa-proxies. These changes were developed by vendoring in our own mono repo at @CloudSoda.

Key Changes

  1. Generic Type Parameters: Added generic type parameters StateT, ContextT, and ResponseBodyT to KoaProxies function. This allows users to specify custom state, context, and response body types, aligning more closely with Koa's native typing system.
  2. Updated IBaseKoaProxiesOptions: Modified the IBaseKoaProxiesOptions interface to accept a generic ContextT type. This change provides better integration with custom Koa contexts.
  3. Enhanced Type Safety: By introducing these generic parameters, the type definitions now offer improved type safety and developer experience in TypeScript environments.

Motivation

Our project's requirements and the limitations encountered with the current TypeScript definitions in koa-proxies led us to develop our own custom definitions. The primary motivation was to achieve better type support for custom Koa contexts and to enhance the TypeScript integration for more complex use cases.

Impact

  • Backward Compatibility: These changes are designed to be backward compatible. Projects using the standard koa-proxies TypeScript definitions should remain unaffected.
  • Developer Experience: The new definitions offer a more seamless and type-safe integration for TypeScript users of koa-proxies, particularly those dealing with complex or custom Koa contexts.

We are excited to contribute these improvements back to the koa-proxies community and look forward to feedback and suggestions!

rilopez avatar Jan 11 '24 05:01 rilopez