Prerequisites
Fastify version
4.0.0
Plugin version
5.0.0
Node.js version
16.16.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.4
Description
When attempting to use the transact route option using typescript, passing in the transact route options and referencing pg
from the request object throws typescript type errors. This is because because pg
has not been added to FastifyRequest and
interface FastifyPostgresRouteOptions {
transact: boolean | string;
}
has not been added for pg
for RouteShorthandOptions
Steps to Reproduce
fastify.post(
'/',
{
pg: { transact: true }, // Throws type error for RouteShorthandOptions
},
async (req, _reply) => {
req.pg.query('SELECT * FROM table') // Throws type error for FastifyRequest
}
);
Expected Behavior
Using the route transact option should not cause compile errors in typescript