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

SaveOptions type is missing hooks option #12441

Closed
2 of 7 tasks
cnorthwood opened this issue Jun 29, 2020 · 2 comments
Closed
2 of 7 tasks

SaveOptions type is missing hooks option #12441

cnorthwood opened this issue Jun 29, 2020 · 2 comments
Labels
released type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@cnorthwood
Copy link
Contributor

cnorthwood commented Jun 29, 2020

Issue Description

What are you doing?

This TypeScript fails a type check in V6 (given a model is defined)

  const user = await User.findByPk(id);
  if (user === null) {
    return;
  }
  user.lastLogin = new Date();
  await user.save({ hooks: false });

The typing for SaveOptions is missing hooks?: boolean in it. Looking at the code, it appears the hooks option is still there, and it is documented, so this is a type error I think.

What do you expect to happen?

The snippet above should pass a typecheck.

What is actually happening?

error TS2345: Argument of type '{ hooks: boolean; }' is not assignable to parameter of type 'SaveOptions<any>'.

Additional context

Add any other context or screenshots about the feature request here.

Environment

  • Sequelize version: 6.2.3
  • Node.js version: v14.1.0
  • Operating System: macOS
  • If TypeScript related: TypeScript version: 3.9.5

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance. (specifically I don't know where the types are actually defined, I can't see them in this repo)
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@sushantdhiman sushantdhiman added the type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. label Jun 30, 2020
@sushantdhiman
Copy link
Contributor

You can submit a PR for v6 branch, here is the relevant code

export interface SaveOptions<TAttributes = any> extends Logging, Transactionable, Silent {

@sushantdhiman
Copy link
Contributor

🎉 This issue has been resolved in version 6.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

No branches or pull requests

2 participants