Skip to content

Commit cd2de40

Browse files
knoidpapb
andauthored
fix(typings): make Transactionable compatible with TransactionOptions (sequelize#13334)
Co-authored-by: Pedro Augusto de Paula Barbosa <[email protected]>
1 parent 1a16b91 commit cd2de40

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

types/lib/transaction.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export interface TransactionOptions extends Logging {
149149
/**
150150
* Parent transaction.
151151
*/
152-
transaction?: Transaction;
152+
transaction?: Transaction | null;
153153
}
154154

155155
export default Transaction;

types/test/models/User.ts

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ User.addHook('beforeFind', 'test', (options: FindOptions<UserAttributes>) => {
110110
return undefined;
111111
});
112112

113+
User.addHook('afterDestroy', async (instance, options) => {
114+
// `options` from `afterDestroy` should be passable to `sequelize.transaction`
115+
await instance.sequelize.transaction(options, async () => undefined);
116+
});
117+
113118
// Model#addScope
114119
User.addScope('withoutFirstName', {
115120
where: {

0 commit comments

Comments
 (0)