I'm trying to put together a simple endpoint following the Fastify with Typescript docs here:
https://www.fastify.io/docs/v3.1.x/TypeScript/
export default async function foo(fastify: any) { const MyInstance = new Foo(fastify.db); app.get<{ Querystring: IQueryString, Headers: IHeaders }>( "/foo", async (request: FastifyRequest, reply: FastifyReply) => { console.log(request.query); // *prints query object* const { queryObj } = request.query; // *Gives error: Object is of type 'unknown'* const result = await MyInstance.getFoo(queryObj); reply.status(200).send(result); } ); } Why do I get the error when I try to access the request.query object and how do I fix it?
async (request, reply) =>instead ofasync (request: FastifyRequest, reply: FastifyReply) =>. Note: the examples in the docs you linked do this properlyasync(request, reply). I get no implicit any onrequestandreply.