Sequelize-typescript: typescript error from 2.0.0-beta.0 and sequelize 6.1.1

Created on 16 Jul 2020  路  2Comments  路  Source: RobinBuschmann/sequelize-typescript

Versions

sequelize: ^6.1.1
sequelize-typescript: 2.0.0-beta.0
typescript: ^3.9.3

I'm submitting a ...

[x] bug report
[ ] feature request

Actual behavior:

Type 'typeof ProductsProperties' is not assignable to type 'typeof Model'.
  Construct signature return types 'ProductsProperties' and 'Model<TModelAttributes, TCreationAttributes>' are incompatible.
    The types of '_attributes' are incompatible between these types.
      Type 'ProductsProperties' is not assignable to type 'TModelAttributes'.

Model class:

import { Model } from 'sequelize-typescript'

export interface ProductsPropertiesAttributes {
  id?: number
  value: string
  createdAt: Date
}

export class ProductsProperties extends Model<ProductsProperties, ProductsPropertiesAttributes> {
   ...
}

Error getting in below code where the model is having red line:

this.productsModel.findByPk(keycode, {
      attributes: ['keycode', 'name'],
      include: [{
        model: ProductsProperties
      }]
    })

Most helpful comment

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.

All 2 comments

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.

Last commit on master: https://github.com/RobinBuschmann/sequelize-typescript/commit/135b88eaac1f3ec35ea509a5664fa3818ce0f1c3 is entitled rollback to 6.1.1 because of build error in 6.2.0.

In your package.json file, replace for sequelize ^6.1.1 to 6.1.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fareshan picture fareshan  路  3Comments

lilling picture lilling  路  4Comments

oscarcalvo picture oscarcalvo  路  3Comments

josecolella picture josecolella  路  4Comments

fareshan picture fareshan  路  4Comments