mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
Change transaction() autoCallback param type from Blueburd to PromiseLike (#16253)
* Change transaction() autoCallback param type from Blueburd to PromiseLike * Add promise tests.
This commit is contained in:
committed by
Mohamed Hegazy
parent
74818a2559
commit
d1a979d719
4
types/sequelize/index.d.ts
vendored
4
types/sequelize/index.d.ts
vendored
@@ -5726,8 +5726,8 @@ declare namespace sequelize {
|
||||
* @param autoCallback Callback for the transaction
|
||||
*/
|
||||
transaction(options: TransactionOptions,
|
||||
autoCallback: (t: Transaction) => Promise<any>): Promise<any>;
|
||||
transaction(autoCallback: (t: Transaction) => Promise<any>): Promise<any>;
|
||||
autoCallback: (t: Transaction) => PromiseLike<any>): Promise<any>;
|
||||
transaction(autoCallback: (t: Transaction) => PromiseLike<any>): Promise<any>;
|
||||
transaction(): Promise<Transaction>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Sequelize = require("sequelize");
|
||||
import Promise = require('bluebird');
|
||||
import Q = require('q');
|
||||
import Bluebird = require('bluebird');
|
||||
|
||||
//
|
||||
// Fixtures
|
||||
@@ -978,7 +979,7 @@ User.create( { title : 'Chair', creator : { first_name : 'Matt', last_name : 'Ha
|
||||
User.create( { id : 1, title : 'e', Tags : [{ id : 1, name : 'c' }, { id : 2, name : 'd' }] }, { include : [User] } );
|
||||
User.create( { id : 'My own ID!' } ).then( ( i ) => i.isNewRecord );
|
||||
|
||||
let findOrRetVal: Promise<[AnyInstance, boolean]>;
|
||||
let findOrRetVal: Bluebird<[AnyInstance, boolean]>;
|
||||
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' } } );
|
||||
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' }, transaction : t } );
|
||||
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' }, defaults : { foo : 'asd' }, transaction : t } );
|
||||
@@ -1617,18 +1618,33 @@ s.transaction().then( function( t ) {
|
||||
} );
|
||||
|
||||
s.transaction( function() {
|
||||
return Promise.resolve();
|
||||
return Bluebird.resolve();
|
||||
} );
|
||||
s.transaction( { isolationLevel : 'SERIALIZABLE' }, function( t ) { return Promise.resolve(); } );
|
||||
s.transaction( { isolationLevel : s.Transaction.ISOLATION_LEVELS.SERIALIZABLE }, (t) => Promise.resolve() );
|
||||
s.transaction( { isolationLevel : s.Transaction.ISOLATION_LEVELS.READ_COMMITTED }, (t) => Promise.resolve() );
|
||||
s.transaction( { isolationLevel : 'SERIALIZABLE' }, function( t ) { return Bluebird.resolve(); } );
|
||||
s.transaction( { isolationLevel : s.Transaction.ISOLATION_LEVELS.SERIALIZABLE }, (t) => Bluebird.resolve() );
|
||||
s.transaction( { isolationLevel : s.Transaction.ISOLATION_LEVELS.READ_COMMITTED }, (t) => Bluebird.resolve() );
|
||||
|
||||
// transaction types
|
||||
new Sequelize( '', { transactionType: 'DEFERRED' } );
|
||||
new Sequelize( '', { transactionType: Sequelize.Transaction.TYPES.DEFERRED} );
|
||||
new Sequelize( '', { transactionType: Sequelize.Transaction.TYPES.IMMEDIATE} );
|
||||
new Sequelize( '', { transactionType: Sequelize.Transaction.TYPES.EXCLUSIVE} );
|
||||
s.transaction( { type : 'DEFERRED' }, (t) => Promise.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.DEFERRED }, (t) => Promise.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.IMMEDIATE }, (t) => Promise.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.EXCLUSIVE }, (t) => Promise.resolve() );
|
||||
s.transaction( { type : 'DEFERRED' }, (t) => Bluebird.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.DEFERRED }, (t) => Bluebird.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.IMMEDIATE }, (t) => Bluebird.resolve() );
|
||||
s.transaction( { type : s.Transaction.TYPES.EXCLUSIVE }, (t) => Bluebird.resolve() );
|
||||
|
||||
// promise transaction
|
||||
s.transaction(async () => {
|
||||
});
|
||||
s.transaction((): Promise<void> => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
s.transaction((): Bluebird<void> => {
|
||||
return Bluebird.resolve();
|
||||
});
|
||||
s.transaction((): Q.Promise<void> => {
|
||||
return Q.Promise<void>((resolve) => {
|
||||
resolve(null);
|
||||
});
|
||||
});
|
||||
|
||||
4
types/sequelize/v3/index.d.ts
vendored
4
types/sequelize/v3/index.d.ts
vendored
@@ -5692,8 +5692,8 @@ declare namespace sequelize {
|
||||
* @param autoCallback Callback for the transaction
|
||||
*/
|
||||
transaction(options: TransactionOptions,
|
||||
autoCallback: (t: Transaction) => Promise<any>): Promise<any>;
|
||||
transaction(autoCallback: (t: Transaction) => Promise<any>): Promise<any>;
|
||||
autoCallback: (t: Transaction) => PromiseLike<any>): Promise<any>;
|
||||
transaction(autoCallback: (t: Transaction) => PromiseLike<any>): Promise<any>;
|
||||
transaction(): Promise<Transaction>;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user