Skip to content

fix(types): Allow transaction to be null in Transactionable interface (#13092).#13093

Merged
papb merged 3 commits into
sequelize:mainfrom
yjwong:main
Mar 13, 2021
Merged

fix(types): Allow transaction to be null in Transactionable interface (#13092).#13093
papb merged 3 commits into
sequelize:mainfrom
yjwong:main

Conversation

@yjwong
Copy link
Copy Markdown
Contributor

@yjwong yjwong commented Mar 11, 2021

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions? (typing issue)
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

When using TypeScript with strictNullChecks enabled, we cannot pass null to transaction, but this is actually allowed and used to execute in a non-transaction context when in an auto-transaction block.

Closes #13092.

I wish for this change to also be backported to v5. How do I go about doing that?

@papb
Copy link
Copy Markdown
Member

papb commented Mar 12, 2021

Hello! Thanks!

Copy link
Copy Markdown
Member

@papb papb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you please add a typings test here for this?

@papb
Copy link
Copy Markdown
Member

papb commented Mar 12, 2021

I wish for this change to also be backported to v5. How do I go about doing that?

You create a new branch off the v5 branch, do the same changes you did here (including a test, please), and open a new pull request selecting v5 as the target branch (instead of main). And write something like this in its description:

This PR is a backport of #13093 into v5

@papb papb added the status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action label Mar 12, 2021
@yjwong
Copy link
Copy Markdown
Contributor Author

yjwong commented Mar 13, 2021

I tried running npm run test-typings locally but got this output:

> sequelize@0.0.0-development test-typings /home/yjwong/Documents/sequelize
> tsc -b types/tsconfig.json && tsc -b types/test/tsconfig.json

types/test/define.ts:30:43 - error TS2511: Cannot create an instance of an abstract class.

30   expectTypeOf<UserModel>().toMatchTypeOf(new User());
                                             ~~~~~~~~~~

types/test/define.ts:63:50 - error TS2511: Cannot create an instance of an abstract class.

63   expectTypeOf<UntypedUserModel>().toMatchTypeOf(new UntypedUser());
                                                    ~~~~~~~~~~~~~~~~~


Found 2 errors.

These errors doesn't seem to be related to the tests I added.

@papb
Copy link
Copy Markdown
Member

papb commented Mar 13, 2021

@yjwong Hmm, that's weird, but since tests are passing on GitHub Actions, don't worry about it. Just in case, can you confirm what is your TS local version?

@yjwong
Copy link
Copy Markdown
Contributor Author

yjwong commented Mar 13, 2021

@papb I found out why, I manually installed TypeScript 4.1.x using npm install --save-dev typescript@~4.1 and it ran without error. Seems like it's more of an issue with TypeScript 4.2.x.

Seems like it's related to this change: https://devblogs.microsoft.com/typescript/announcing-typescript-4-2/#abstract-construct-signatures

But that's probably a different issue altogether.

@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

This was referenced Mar 15, 2021
danielschwartz pushed a commit to danielschwartz/sequelize that referenced this pull request Mar 15, 2021
jctaveras pushed a commit to jctaveras/sequelize that referenced this pull request Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript: The Transactionable interface should also accept null

2 participants