<commit_before>import { Deferrable, Sequelize, Transaction } from 'sequelize';
import { User } from './models/User';

export const sequelize = new Sequelize('uri');

async function trans() {
    const a: number = await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.create(
            {
                data: 123,
            },
            {
                transaction,
            }
        );
        return 1;
    });
}

async function trans2() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: transaction.LOCK.UPDATE,
            }
        );
        return 1;
    });
}

async function trans3() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: true,
            }
        );
        return 1;
    });
}

async function trans4() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: {
                    level: transaction.LOCK.UPDATE,
                    of: User,
                },
            }
        );
        return 1;
    });
}

async function transact() {
    const t = await sequelize.transaction({
        deferrable: Deferrable.SET_DEFERRED(['test']),
        isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED,
        type: Transaction.TYPES.DEFERRED,
    });
    await t.commit();
    await t.rollback();
}

transact();

async function nestedTransact() {
  const tr = await sequelize.transaction({
    transaction: await sequelize.transaction(),
  });
  await tr.commit();
}
<commit_msg>fix(types): add test for the case where transaction is null<commit_after>import { Deferrable, Sequelize, Transaction } from 'sequelize';
import { User } from './models/User';

export const sequelize = new Sequelize('uri');

async function trans() {
    const a: number = await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.create(
            {
                data: 123,
            },
            {
                transaction,
            }
        );
        return 1;
    });
}

async function trans2() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: transaction.LOCK.UPDATE,
            }
        );
        return 1;
    });
}

async function trans3() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: true,
            }
        );
        return 1;
    });
}

async function trans4() {
    return await sequelize.transaction(async transaction => {
        transaction.afterCommit(() => console.log('transaction complete'));
        User.findAll(
            {
                transaction,
                lock: {
                    level: transaction.LOCK.UPDATE,
                    of: User,
                },
            }
        );
        return 1;
    });
}

async function transact() {
    const t = await sequelize.transaction({
        deferrable: Deferrable.SET_DEFERRED(['test']),
        isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED,
        type: Transaction.TYPES.DEFERRED,
    });
    await t.commit();
    await t.rollback();
}

transact();

async function nestedTransact() {
  const tr = await sequelize.transaction({
    transaction: await sequelize.transaction(),
  });
  await tr.commit();
}

async function excludeFromTransaction() {
  await sequelize.transaction(async t =>
    sequelize.query('SELECT 1', { transaction: null })
  );
}

{'fraction_non_alphanumeric': 0.11673699015471167, 'fraction_numerical': 0.004922644163150493, 'mean_word_length': 1.8734006734006734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598738', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1088, 'n_words': 247}