koa-proxies
koa-proxies copied to clipboard
feat(typescript): improve TS definitions for better context support
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
-
Generic Type Parameters: Added generic type parameters
StateT
,ContextT
, andResponseBodyT
toKoaProxies
function. This allows users to specify custom state, context, and response body types, aligning more closely with Koa's native typing system. -
Updated
IBaseKoaProxiesOptions
: Modified theIBaseKoaProxiesOptions
interface to accept a genericContextT
type. This change provides better integration with custom Koa contexts. - 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!