typescript @Types/Sequelize 错误 TS1086:无法在环境上下文中声明访问器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58802463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
@Types/Sequelize Error TS1086: An accessor cannot be declared in ambient context
提问by Josel567
I have a project that shows this error when I run '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;
~~~~
My versions are:
我的版本是:
- "@types/sequelize": "^4.28.6"
- "sequelize": "^5.8.10"
- "sequelize-typescript": "1.0.0-beta.4"
- "@types/sequelize": "^4.28.6"
- “续集”:“^5.8.10”
- "sequelize-typescript": "1.0.0-beta.4"
The project works fine with nodemon but fails when I try to compile the typescript. Anyone knows this error?
该项目在 nodemon 上运行良好,但在我尝试编译打字稿时失败。有人知道这个错误吗?
Thanks.
谢谢。
回答by krishn Patel
I have Angular 8. it is working with typescript version of 3.4.5. so solve this issue do below steps.
我有Angular 8。它正在使用 3.4.5 的打字稿版本。所以解决这个问题做下面的步骤。
step 1) go to the tsconfig.jsonfile
步骤 1) 转到tsconfig.json文件
step 2) add skipLibCheck: truein "compilerOptions" object. It works for me.
步骤2)在“compilerOptions”对象中添加skipLibCheck:true。这个对我有用。
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"target": "es5",
"declaration": true,
"declarationDir": "dist-debug/",
"skipLibCheck": true, /// Needs to be true to fix wrong alias types being used
},
回答by Aviad Hadad
you need to use typescript 3.7.
您需要使用打字稿 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.
so presumably sequelize
was compiled with typescript 3.7 and emits definition files that previous versions don't understand. So you'll need to upgrade to typescript 3.7 or use an earlier version of sequelize.
所以大概sequelize
是用 typescript 3.7 编译的,并发出以前版本不理解的定义文件。因此,您需要升级到 typescript 3.7 或使用更早版本的 sequelize。
回答by kimamula
Setting "skipLibCheck": true
worked for me.
设置"skipLibCheck": true
对我有用。