TypeScript type for request object for route handlers

So far I've been writing my routes like:
export const router = t.router({
helloWorld: t.procedure.query(async (req) => "Hello World"),
})
export const router = t.router({
helloWorld: t.procedure.query(async (req) => "Hello World"),
})
What would be the type for req if I wanted to extract my handlers like so:
const handler = async (req:?) => "Hello World"

export const router = t.router({
helloWorld: t.procedure.query(hander)
})
const handler = async (req:?) => "Hello World"

export const router = t.router({
helloWorld: t.procedure.query(hander)
})
N
Nick385d ago
You'll have a really hard time extracting your handlers in some cases, but for this simple example you can just use some typescript magic
type QueryInputs = Parameters<typeof t.procedure.query>[0]
type QueryInputs = Parameters<typeof t.procedure.query>[0]
M
meow385d ago
ah thx