RFC: Middleware Appliers for Third Party Middlewares #5112
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A problem we continue to have with the experimental standalone middlewares, and also t.middleware, is that they have caused many bugs with type inference over time, and so compose unreliably. It's not clear that all problems are solvable.
This is an approach which draws inspiration from other libraries like Tanstack Router, and simply doesn't try to fight the typescript type system by making everything into a function call of known type
I copied over the minimal example project for this prototype so the diff looks bigger than it should, focus on:
AcmeMiddleware.ts
: https://github.com/trpc/trpc/pull/5112/files#diff-860c9b23a905a4f6494e0cf370a317bde88b6e702ba3cb26db9ba79115fb1b78trpc.ts
: https://github.com/trpc/trpc/pull/5112/files#diff-9cfcb5afca1d1d2518a9465e6aba2367ea9e39aa0236e19a634a7b1a13854341index.ts
: https://github.com/trpc/trpc/pull/5112/files#diff-ebbbc5e7b43d53fbdc9a56f8f3125a6470d7dcfc7ce4114a4402d63f3e591f99Next
type: https://github.com/trpc/trpc/pull/5112/files#diff-28374e196350161477845434683132162955a507c4d6ff3bebad3774ebb0749d🎯 Changes
What changes are made in this PR? Is it a feature or a bug fix?
✅ Checklist