Closed cmaycumber closed 1 year ago
Hey @cmaycumber
Could you provide an example of what you mean?
You should check this project https://github.com/omar-dulaimi/prisma-trpc-shield-generator to automate creation of shield.
for instance, rule function has no way of passing generics to describe the context shape
I agree that having better type inference would be good. The prisma generator can't always be used since not everyone uses prisma or doesn't want to have auto-generated trpc endpoints.
For further elaboration: the type of the passed context, which is pretty important when working with authentication, can't be inferred since this package only declares MiddlewareFunction<any, any, any>;
as the return type of the middleware. Furthermore, when constructing the IRules
argument of shield
, it can't do type inference using the given context and instead just uses a default.
Yeah @douira, I guess that is a useful enhancement to implement. I'm planning to do so after upgrading the tRPC generator to v10 soon.
Released in https://github.com/omar-dulaimi/trpc-shield/releases/tag/0.3.0
Check the README to learn how to correctly use it.
I tested it and everything seems to be working as expected. You get full type safety just like tRPC. Please feel free to open new issues if you face any.
Also, consider sponsoring this or any of my other projects for continued support and features :)
Least you can do is star the project!
Feature request
Is your feature request related to a problem? Please describe
Typescript support for shield method
Describe the solution you'd like
Typed records inside of the shield based on AppRouter
Describe alternatives you've considered
No typescript support