gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 22:09:51 25 4
gpt4 key购买 nike

我有一个项目,当我运行“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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com