mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
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.
This commit is contained in:
Vendored
+1
-1
@@ -17,7 +17,7 @@ interface Bookshelf extends Bookshelf.Events<any> {
|
||||
Collection: typeof Bookshelf.Collection;
|
||||
|
||||
plugin(name: string | string[] | Function, options?: any): Bookshelf;
|
||||
transaction<T>(callback: (transaction: knex.Transaction) => BlueBird<T>): BlueBird<T>;
|
||||
transaction<T>(callback: (transaction: knex.Transaction) => PromiseLike<T>): BlueBird<T>;
|
||||
}
|
||||
|
||||
declare function Bookshelf(knex: knex): Bookshelf;
|
||||
|
||||
Reference in New Issue
Block a user