Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rilopez
Copy link

@rilopez rilopez commented Jan 11, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant