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

Error when defining relationships (BelongsTo, ForeignKey, HasMany etc) #821

Closed
Evanion opened this issue Jul 29, 2020 · 5 comments · Fixed by #900
Closed

Error when defining relationships (BelongsTo, ForeignKey, HasMany etc) #821

Evanion opened this issue Jul 29, 2020 · 5 comments · Fixed by #900

Comments

@Evanion
Copy link

Evanion commented Jul 29, 2020

Versions

  • sequelize: ^6.3.3
  • sequelize-typescript: ^1.1.0
  • typescript: ^3.9.7

I'm submitting a ...

[x ] bug report
[ ] feature request

Actual behavior:
I'm getting a type error when I try and define a relationship between Models

Expected behavior:
Being able to define relationships as per the docs and examples

Related code:
Screenshot 2020-07-29 at 15 40 12
Screenshot 2020-07-29 at 15 49 25
Screenshot 2020-07-29 at 15 49 39
Screenshot 2020-07-29 at 15 56 36
Screenshot 2020-07-29 at 15 56 47

@maracaipe
Copy link

maracaipe commented Jul 30, 2020

Hi @Evanion, this is the same issue at lot of people are having here. I have commented on issue #813 this:

I have this same issue. Could resolve this by removing the type constructor (<Questions>, <Options>).

In my case I had a QuestionsAttributes interface and had to change:

class TalentData extends Model<TalentData, TalentDataAttributes>

to:

class TalentData extends Model implements TalentDataAttributes

But this really appears to be a sequelize-typescript error.

@RobinBuschmann any thoughts on that?

@crrobinson14
Copy link

I had this same issue this morning and cross-compared my current project against one that was still working. I noticed I had a few modules with later versions, especially Typescript, Sequelize itself, and some of the @types incudes, so I downgraded them and this resolved the problem.

For reference, this is working for me. Later versions of Sequelize and other deps are not:

  "dependencies": {
    "mysql2": "^2.1.0",
    "reflect-metadata": "^0.1.13",
    "sequelize": "^5.22.2",
    "sequelize-typescript": "^1.1.0"
  },
  "devDependencies": {
    "@types/sequelize": "^4.28.9",
    "@types/bluebird": "^3.5.32",
    "@types/validator": "^13.0.0",
    "@types/node": "^14.0.13",
    "typescript": "^3.9.5"
  },

@archer747
Copy link

Yeah, having similar issue. Downgraded from v 6 to "sequelize": "^5.22.2" and error disappeared.

@ltbittner
Copy link

+1 Getting the same error. Downgrading to 5.22.2 also resolved the issue for me.

@vanthome
Copy link

vanthome commented Aug 6, 2020

Same here, a fix would be great

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 a pull request may close this issue.

6 participants