From 2373810e8d3f9be1248059b895ca0dfda58c0146 Mon Sep 17 00:00:00 2001 From: Steve Xian Date: Wed, 1 Nov 2017 17:25:25 -0700 Subject: [PATCH 1/2] The existing code forces the transaction to return a bluebird promise, which is incompatiable with es6 promises and async/await. Thus if the user application is written in es6 promises with async/await, and have to return a bluebird promise in order to use bookshelf transactions, it becomes a burden to translate. The bookshelf.transaction is an alias for knex.transaction(http://bookshelfjs.org/#Bookshelf-instance-transaction), and the knex.transaction uses any as a return type instead of promise. I updated the return type of the user supplied function to PromiseLike, which both es6 and bluebird promises implement. Tested with both bluebird and es6 promises. --- types/bookshelf/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/bookshelf/index.d.ts b/types/bookshelf/index.d.ts index bb817d3074..d805eef077 100644 --- a/types/bookshelf/index.d.ts +++ b/types/bookshelf/index.d.ts @@ -17,7 +17,7 @@ interface Bookshelf extends Bookshelf.Events { Collection: typeof Bookshelf.Collection; plugin(name: string | string[] | Function, options?: any): Bookshelf; - transaction(callback: (transaction: knex.Transaction) => BlueBird): BlueBird; + transaction(callback: (transaction: knex.Transaction) => PromiseLike): BlueBird; } declare function Bookshelf(knex: knex): Bookshelf; From ef74cd057eb6f863b596ff4768886bb7a21511cf Mon Sep 17 00:00:00 2001 From: Steve Xian Date: Wed, 1 Nov 2017 17:35:05 -0700 Subject: [PATCH 2/2] incremented version --- types/bookshelf/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/bookshelf/index.d.ts b/types/bookshelf/index.d.ts index d805eef077..dca8d5fad2 100644 --- a/types/bookshelf/index.d.ts +++ b/types/bookshelf/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for bookshelfjs v0.9.3 +// Type definitions for bookshelfjs v0.9.4 // Project: http://bookshelfjs.org/ // Definitions by: Andrew Schurman , Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped