Jacob
Jacob
Explore posts from servers
TtRPC
Created by Jacob on 5/27/2024 in #❓-help
Losing type-safety with merged routers
When using router exported from an external file, I lose any sort of type safety for the procedures on in that router. router.ts
export const appRouter = router({
users: usersRouter,
test: {
create: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
}),
list: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
})
}
})
export const appRouter = router({
users: usersRouter,
test: {
create: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
}),
list: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
})
}
})
users.ts
export const usersRouter = router({
create: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
}),
list: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
})
});
export const usersRouter = router({
create: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
}),
list: procedure.input(z.string()).query(({ input }) => {
return 'Hi ' + input;
})
});
On my frontend I call the trpc object api api.test is typed as expected, api.users however is any. I can quite figure out what I'm doing wrong 🤔
5 replies
TtRPC
Created by Jacob on 11/5/2023 in #❓-help
The inferred type of 'trpc' cannot be named without a reference ...
No description
5 replies