node.js - @Types/Sequelize 错误 TS1086 : An accessor cannot be declared in ambient context

标签 node.js typescript types sequelize.js tsc

我有一个项目,当我运行“tsc”时显示此错误:

../modules/node_modules/sequelize/types/lib/transaction.d.ts:33:14 - error TS1086: An accessor cannot be declared in an ambient context.

33   static get LOCK(): LOCK;
                ~~~~

../modules/node_modules/sequelize/types/lib/transaction.d.ts:40:7 - error TS1086: An accessor cannot be declared in an ambient context.

40   get LOCK(): LOCK;
         ~~~~

我的版本是:
  • "@types/sequelize": "^4.28.6"
  • "Sequelize ": "^5.8.10"
  • "sequelize-typescript": "1.0.0-beta.4"

  • 该项目在 nodemon 上运行良好,但在我尝试编译 typescript 时失败。有人知道这个错误吗?

    谢谢。

    最佳答案

    您需要使用 typescript 3.7。

    from typescript 3.7 release notes:

    To detect the issue around accessors, TypeScript 3.7 will now emit get/set accessors in .d.ts files so that in TypeScript can check for overridden accessors.
    
    

    所以大概 sequelize 是用 typescript 3.7 编译的,并发出以前版本不理解的定义文件。因此,您需要升级到 typescript 3.7 或使用更早版本的 sequelize。

    关于node.js - @Types/Sequelize 错误 TS1086 : An accessor cannot be declared in ambient context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58802463/

    相关文章:

    node.js - 如何通过 BrowserSync 中间件设置 session cookie?

    javascript - 如何将backbone.js 与websockets/socket-io/nowjs 一起使用

    perl - Perl 中的类型转换

    typescript :函数声明中接口(interface)属性的类型安全

    javascript - 为什么 Angular 构建创建的文件包含 'es5' 和 'es2015' 而不是 'es6'(或根本没有后缀)?

    java - 如何在 Java 中将 10 乘以 "Integer"对象?

    function - 如何在 Chapel 中编写模板函数的类型签名

    node.js - 用于 nodejs Upstart 的配置文件

    node.js - 使用 Nodejs 的 Gmail API 推送通知

    typescript - 如何在没有任何或对象的情况下制作 TypeScript 类型保护?