diff --git a/test-tsd/transaction.test-d.ts b/test-tsd/transaction.test-d.ts index 4ad999a764..d61ae5ff84 100644 --- a/test-tsd/transaction.test-d.ts +++ b/test-tsd/transaction.test-d.ts @@ -25,6 +25,18 @@ const main = async () => { .returning(['id', 'subject']); })); + expectType[]>(await knexInstance.transaction((trx) => { + const articles: Article[] = [ + { id: 1, subject: 'Canterbury Tales' }, + { id: 2, subject: 'Moby Dick' }, + { id: 3, subject: 'Hamlet' }, + ]; + return trx + .insert(articles) + .into
('articles') + .returning(['id', trx.raw('subject')]); + })); + expectType(await knexInstance.transaction((trx) => { return trx .select('*') diff --git a/types/index.d.ts b/types/index.d.ts index ef6617b501..dbba821adf 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -914,7 +914,7 @@ export declare namespace Knex { options?: DMLOptions ): QueryBuilder; returning[]>( - column: string | readonly string[], + column: string | readonly (string | Raw)[] | Raw, options?: DMLOptions ): QueryBuilder; @@ -1007,7 +1007,7 @@ export declare namespace Knex { options?: DMLOptions ): QueryBuilder; delete( - returning: string | readonly string[], + returning: string | readonly (string | Raw)[] | Raw, options?: DMLOptions ): QueryBuilder; delete(): QueryBuilder; @@ -1781,7 +1781,7 @@ export declare namespace Knex { ): BatchInsertBuilder; // if data with specific type passed, exclude this method returning[]>( - column: unknown extends TRecord ? string | readonly string[] : never + column: unknown extends TRecord ? string | readonly (string | Raw)[] | Raw: never ): BatchInsertBuilder; }