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

v6.14.0+ breakes existing model types #14129

Closed
1 of 7 tasks
snitin315 opened this issue Feb 17, 2022 · 2 comments · Fixed by #14146
Closed
1 of 7 tasks

v6.14.0+ breakes existing model types #14129

snitin315 opened this issue Feb 17, 2022 · 2 comments · Fixed by #14146
Assignees
Labels
type: bug type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@snitin315
Copy link

snitin315 commented Feb 17, 2022

Issue Creation Checklist

[ ] I have read the contribution guidelines

Bug Description

SSCCE

**Here is the link to the SSCCE for this issue: opencollective/opencollective-api#7142

// You can delete this code block if you have included a link to your SSCCE above!
import { PaypalProductCreateAttributes } from './PaypalProduct';

interface PaypalPlanAttributes {
  id: string;
  ProductId: string;
  currency: string;
  interval: string;
  amount: number;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date;
}

interface PaypalPlanCommonCreateAttributes {
  id: string;
  currency: string;
  interval: string;
  amount: number;
}

interface PaypalPlanCreateWithProductIdAttributes extends PaypalPlanCommonCreateAttributes {
  ProductId?: string;
}

interface PaypalPlanCreateWithProductAttributes extends PaypalPlanCommonCreateAttributes {
  product?: PaypalProductCreateAttributes;
}

type PaypalPlanCreateAttributes = PaypalPlanCreateWithProductIdAttributes | PaypalPlanCreateWithProductAttributes;


class PaypalPlan extends Model<PaypalPlanAttributes, PaypalPlanCreateAttributes> implements PaypalPlanAttributes {
  id: string;
  ProductId: string;
  currency: string;
  interval: string;
  amount: number;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date;
  constructor(...args) {
    super(...args);
    restoreSequelizeAttributesOnClass(new.target, this);
  }
}

What do you expect to happen?

No typescript errors for v6.13.0 and before.

What is actually happening?

Screenshot 2022-02-16 at 6 53 13 AM

Additional context

Using intersection instead of union is fixing it, but we do not want an intersection here.

- type PaypalPlanCreateAttributes = PaypalPlanCreateWithProductIdAttributes | PaypalPlanCreateWithProductAttributes;
+ type PaypalPlanCreateAttributes = PaypalPlanCreateWithProductIdAttributes & PaypalPlanCreateWithProductAttributes;

Environment

  • Sequelize version: XXX
  • Node.js version: XXX
  • If TypeScript related: TypeScript version: XXX

Bug Report 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.
  • 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.
@fzn0x fzn0x added type: bug type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. labels Feb 17, 2022
@ephys ephys self-assigned this Feb 17, 2022
@snitin315
Copy link
Author

Fixed in #14146

@ephys
Copy link
Member

ephys commented Feb 25, 2022

Happy to hear it worked 🎉 (also surprised github didn't link the issue to the PR)

@ephys ephys linked a pull request Feb 25, 2022 that will close this issue
6 tasks
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

Successfully merging a pull request may close this issue.

3 participants