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

Associations created by Model.create can't be typed #15420

Open
3 of 6 tasks
ephys opened this issue Dec 8, 2022 · 0 comments
Open
3 of 6 tasks

Associations created by Model.create can't be typed #15420

ephys opened this issue Dec 8, 2022 · 0 comments
Labels
type: bug type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@ephys
Copy link
Member

ephys commented Dec 8, 2022

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

Model.create's typing has no way of knowing that one of the properties is an association:

class Project extends Model<InferAttributes<Project>> {}

class User extends Model<InferAttributes<User>> {
  // hasMany association to Project
  declare projects?: NonAttribute<Project>;
}

User.create({
  // this errors, but it should not.
  projects: {
    // project data
  },
}, {
  include: 'projects',
});

I'm not sure we can fix that before implementing #14302

Related issues:

Environment

  • Sequelize version: 7 alpha 19
  • Node.js version: 18
  • If TypeScript related: TypeScript version: 4.9
  • Database & Version: N/A
  • Connector library & Version: N/A

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 will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

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

No branches or pull requests

1 participant