Skip to content

✨ Export MiddlewareSlot utility type from context-api#208

Open
taras wants to merge 2 commits intomainfrom
feat/export-middleware-slot-type
Open

✨ Export MiddlewareSlot utility type from context-api#208
taras wants to merge 2 commits intomainfrom
feat/export-middleware-slot-type

Conversation

@taras
Copy link
Copy Markdown
Member

@taras taras commented Apr 5, 2026

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 from Around<A>, which is fragile — if the mapping changes, hand-rolled extractions silently drift.

Approach

Export MiddlewareSlot<A, K> — a type alias defined as Around<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

  • New Features
    • Added a developer-facing type convenience to simplify middleware slot configuration for individual API operations.
  • Chores
    • Bumped package version to 0.6.0.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6414a7a-6d41-4a46-aaa6-7d9e34613a25

📥 Commits

Reviewing files that changed from the base of the PR and between d76f26f and 3eb628b.

📒 Files selected for processing (1)
  • context-api/package.json

📝 Walkthrough

Walkthrough

Added a new exported type alias MiddlewareSlot<A, K extends keyof A> to context-api/mod.ts, defined as Around<A>[K]. No runtime behavior or control flow changes.

Changes

Cohort / File(s) Summary
Type Alias Addition
context-api/mod.ts
Added exported type alias MiddlewareSlot<A, K extends keyof A> = Around<A>[K] to simplify typing middleware for a single API operation key.
Package Version Bump
context-api/package.json
Updated package version from 0.5.3 to 0.6.0.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • cowboyd
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: exporting a new MiddlewareSlot utility type from context-api, which matches the primary code change.
Description check ✅ Passed The description follows the required template with both Motivation and Approach sections fully completed, clearly explaining the problem and solution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Policy Compliance ✅ Passed Pull request fully complies with all applicable policies: no-agent-marketing, package-json-metadata, and version-bump.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/export-middleware-slot-type

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@effectionx/context-api@208

commit: 3eb628b

@taras taras requested a review from cowboyd April 5, 2026 10:33
Copy link
Copy Markdown
Member

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

2 participants