typescript - nestjs 中的 sequelize 和 typescript 集成错误

标签 typescript nestjs

我正在尝试使用 typescript 使用 sequelize 部署 nestJs。
我正在关注本教程:
https://docs.nestjs.com/techniques/database#sequelize-integration

[00:22:10] Starting compilation in watch mode...

node_modules/sequelize-typescript/dist/model/model/model.d.ts:10:31 - error TS2417: Class static side 'typeof import("/var/www/vhosts/curem/temp/node_modules/sequelize-typescript/dist/model/model/model").Model' incorrectly extends base class static side 'typeof import("/var/www/vhosts/curem/temp/node_modules/sequelize/types/lib/model").Model'.
  The types returned by 'init(...)' are incompatible between these types.
    Type 'Model<any, any>' is not assignable to type 'MS'.
      'MS' could be instantiated with an arbitrary type which could be unrelated to 'Model<any, any>'.

10 export declare abstract class Model<TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> extends OriginModel<TModelAttributes, TCreationAttributes> {
                                 ~~~~~

node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.d.ts:12:5 - error TS2416: Property 'model' in type 'Sequelize' is not assignable to the same property in base type 'Sequelize'.
  Type '<TCreationAttributes, TModelAttributes>(model: string | ModelType<TCreationAttributes, TModelAttributes>) => ModelCtor<Model<any, any>>' is not assignable to type '(modelName: string) => ModelCtor<Model<any, any>>'.
    Type 'import("/var/www/vhosts/curem/temp/node_modules/sequelize-typescript/dist/model/model/model").ModelCtor<import("/var/www/vhosts/curem/temp/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>>' is not assignable to type 'import("/var/www/vhosts/curem/temp/node_modules/sequelize/types/lib/model").ModelCtor<import("/var/www/vhosts/curem/temp/node_modules/sequelize/types/lib/model").Model<any, any>>'.
      Type 'ModelCtor<Model<any, any>>' is not assignable to type 'typeof Model'.
        The types returned by 'init(...)' are incompatible between these types.
          Type 'Model<any, any>' is not assignable to type 'MS'.
            'MS' could be instantiated with an arbitrary type which could be unrelated to 'Model<any, any>'.

12     model<TCreationAttributes, TModelAttributes>(model: string | ModelType<TCreationAttributes, TModelAttributes>): ModelCtor;
       ~~~~~

[00:22:13] Found 2 errors. Watching for file changes.
有谁知道如何解决这个错误?

最佳答案

刚看到这个问题,跟他们上次发布的sequalize版本有关。
试试这个版本:
“续集”:“6.6.2”

关于typescript - nestjs 中的 sequelize 和 typescript 集成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68147730/

相关文章:

compilation - typescript :使用 lib.core.es6.d.ts

javascript - 如何在 Javascript/Typescript 中使用 Storyblok 电子邮件服务?

javascript - 是否可以在nestjs中的一种方法上使用多个装饰器?

node.js - 巢.js | @Exclude() 装饰器在 POST 方法中不起作用

typescript - 在 typescript 中定义对象形状变体

javascript - 未处理的 Promise 拒绝 : Cannot read property 'push' of undefined Value

angular - 带有 Angular 10 的 Roslib

node.js - NextJS process.env。按钮上 undefined variable 单击获取数据

typescript - NestJS GraphQL 数据源

typescript - 如何用Jest单元测试覆盖TypeORM @Column装饰器?