From 6e73af03830c576ff764c84b863a79cd0eb35a8c Mon Sep 17 00:00:00 2001 From: Harjot Singh Date: Sun, 14 Jun 2026 01:18:03 +0530 Subject: [PATCH] fix(types): type pg Client as the constructor (typeof Pg.Client) The plugin assigns `pg.Client` (the class) to `app.pg.Client` at runtime, but the `PostgresDb` type declared it as `Pg.Client` (an instance). This made `new app.pg.Client(...)` fail to type-check with TS2351 "This expression is not constructable" even though it works at runtime. Type the member as `typeof Pg.Client` so it reflects the constructor, and update the type test to assert against `typeof Client`. Signed-off-by: Harjot Singh --- index.d.ts | 2 +- test-types/query.tst.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4516b96..92fee34 100644 --- a/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ type FastifyPostgres = FastifyPluginCallback { expect(app.pg).type.toBeAssignableTo() expect(app.pg.pool).type.toBe() - expect(app.pg.Client).type.toBe() + expect(app.pg.Client).type.toBe() const client = await app.pg.connect() expect(client).type.toBe()