Skip to content

fix: ensure RequestHandler type is accepted in setup functions#2676

Merged
kettanaito merged 3 commits intomswjs:fix/define-networkfrom
FelmonFekadu:fix/accept-request-handler-arrays
Mar 19, 2026
Merged

fix: ensure RequestHandler type is accepted in setup functions#2676
kettanaito merged 3 commits intomswjs:fix/define-networkfrom
FelmonFekadu:fix/accept-request-handler-arrays

Conversation

@FelmonFekadu
Copy link
Contributor

Summary

  • accept base RequestHandler instances in the shared AnyHandler type
  • keep setupWorker and setupServer compatible with explicitly typed RequestHandler[] arrays
  • add regression coverage for both setup APIs

Verification

  • pnpm build
  • pnpm test:ts
  • pnpm test:unit -- --run src/core/experimental/handlers-controller.test.ts test/node/msw-api/setup-server/listHandlers.node.test.ts
  • pnpm lint

Fixes the compatibility gap reported while testing #2650, where arrays typed as RequestHandler[] no longer spread into setupWorker/setupServer.

@kettanaito kettanaito changed the title fix(define-network): accept RequestHandler arrays fix: ensure RequestHandler type is accepted in setup functions Mar 19, 2026
@kettanaito
Copy link
Member

Thanks for raising this, @FelmonFekadu. I've improved the type tests to actually have assertions and cleaned up the manual AnyHandler type from the core. Looks good now.

@kettanaito kettanaito merged commit da20797 into mswjs:fix/define-network Mar 19, 2026
12 checks passed
@FelmonFekadu
Copy link
Contributor Author

Thanks for tightening that up and taking it the rest of the way. I appreciate the cleanup and the stronger type assertions.

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