我有一个项目,当我运行“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;
~~~~
我的版本是:
该项目在 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/