✨ Export MiddlewareSlot utility type from context-api#208
✨ Export MiddlewareSlot utility type from context-api#208
Conversation
Adds a public type alias that extracts the middleware type for a single operation slot, so typed helper functions can reference it directly instead of reconstructing the Around<A> mapping by hand.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a new exported type alias Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
cowboyd
left a comment
There was a problem hiding this comment.
Seems good. If we're going to have it, then we should use it in the definition of Around<A> itself. What about SlotMiddleware, or even PropertyMiddleware which feels more inline with how JS names things.
Motivation
The
Around<A>mapped type defines how each API member maps to its middleware signature, but there is no public type to extract the middleware type for a single slot. Writing generic middleware helpers today requires duplicating the conditional-type logic fromAround<A>, which is fragile — if the mapping changes, hand-rolled extractions silently drift.Approach
Export
MiddlewareSlot<A, K>— a type alias defined asAround<A>[K]. This gives the slot type a stable public name at zero runtime cost, so typed helpers can reference it directly instead of reconstructing the mapping by hand.Summary by CodeRabbit