Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround sequelize types in tests #226

Merged
merged 5 commits into from
May 23, 2020
Merged

fix: workaround sequelize types in tests #226

merged 5 commits into from
May 23, 2020

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented May 21, 2020

One of the travis jobs runs npm install sequelize@next, which now breaks us. This gets things green again with a workaround. I've put in a todo that will become a lint error when we're on a stable version of sequelize using expiring-todo-comments, to make sure we remember to clean up the workaround.

@mmkal mmkal requested a review from papb May 21, 2020 22:17
Copy link
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.

The expiring-todo-comments is a fantastic rule!! Great idea!! However, are you sure it's enabled?

(Apparently it is not enabled in XO by default)

test/storage/sequelize.test.ts Outdated Show resolved Hide resolved
@papb
Copy link
Member

papb commented May 22, 2020

Is there an issue in the main repo tracking this typing error? If not, can you please open one?

(And mention in it the comment you wrote in the code)

@mmkal
Copy link
Contributor Author

mmkal commented May 22, 2020

are you sure it's enabled?

Yes - I changed it to >=5.0.0 locally and got an error in my IDE. I believe it comes in through the unicorn plugin, not xo: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/cec3a9dfa08db1efd166001d604b04d4fa8ab53f/index.js#L26

Re making an issue in the main repo - I'll try to find some time to get a repro that doesn't involve all the baggage of this test, but I don't actually use sequelize itself so might take a little while to get to it.

@mmkal mmkal requested a review from papb May 22, 2020 13:04
Comment on lines 11 to 15
// TODO [sequelize@>=6.0.0] remove when sequelize fixes the types bug
// a change in the types of sequelize@next makes `describe` a static function - see https://github.com/sequelize/sequelize/issues/12296
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
const describeModel = (model: sequelize.Model) => model.describe();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO [sequelize@>=6.0.0] remove when sequelize fixes the types bug
// a change in the types of sequelize@next makes `describe` a static function - see https://github.com/sequelize/sequelize/issues/12296
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
const describeModel = (model: sequelize.Model) => model.describe();
const describeModel = (model: typeof sequelize.Model) => model.describe();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work because we don't have a typeof Model, we have a Model - this is called with the return value of model.sync() - from sequelize: https://github.com/sequelize/sequelize/blob/b2bccb8aa3faeb6a891fd9f7d3858ebff5b9c32f/types/lib/model.d.ts#L1604-L1608

I'm going to change to any for now. It might be that we are using describe wrong and it's working by chance, but this behaviour is currently going to make every PR fail, so I've changed the todo to TODO [>=3.0.0], i.e. it's on us to fix before we ship v3.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, great catch, sorry about that, I am pretty sure the sync type signature is the one wrong then. I will look into it later.

@mmkal mmkal merged commit 03c53a8 into master May 23, 2020
@mmkal mmkal deleted the describe-workaround branch May 23, 2020 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants