sequelize / sequelize/sequelize

Using CreationOptional leads to issues due to CreationAttributeBrand not being exported

Open
#16,268 2 comments 12 reactions 1 assignee View on GitHub

@ephys is already working on this.

Since Feb 2, 2024.

typescript
Dominant language
TypeScript
Stars
30.4k
Forks
4.3k
Avg merge
1d 6h
Merged PRs (30d)
68

Description

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

Typescript compilation error when using CreationOptional.
error TS4053: Return type of public method from exported class has or is using name 'CreationAttributeBrand' from external module "..." but cannot be named.

Reproducible Example
import { CreationOptional, InferAttributes, InferCreationAttributes, Model } from 'sequelize';

export class Test extends Model<InferAttributes<Test>, InferCreationAttributes<Test>> {
  declare id: CreationOptional<number>;
}

in another file

class TestClass {
  async test() {
    return (await Test.create({})).id;
  }
What do you expect to happen?

Expect code to compile.

What is actually happening?

Code does not compile.

Environment
  • Sequelize version: 6.32.1
  • Node.js version: v16.17.1
  • TypeScript version: 4.9.4

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.