Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js @类型/续集错误TS1086:无法在环境上下文中声明访问器_Node.js_Typescript_Types_Sequelize.js_Tsc - Fatal编程技术网

Node.js @类型/续集错误TS1086:无法在环境上下文中声明访问器

Node.js @类型/续集错误TS1086:无法在环境上下文中声明访问器,node.js,typescript,types,sequelize.js,tsc,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/type

我有一个项目在运行“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”
  • “续集”:“^5.8.10”
  • “续集类型脚本”:“1.0.0-beta.4”
该项目在nodemon上运行良好,但在我尝试编译typescript时失败了。有人知道这个错误吗


谢谢。

您需要使用typescript 3.7


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

设置
“skipLibCheck”:true
对我有效。

我有Angular 8。它正在使用typescript版本的3.4.5。所以要解决这个问题,请执行以下步骤

步骤1)转到tsconfig.json文件

步骤2)在“编译器选项”对象中添加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

  },

如果我不能升级到3.7怎么办?还有其他想法吗?@ShlomiLevi使用早期版本的
@types/sequelize
你是对的,我最近有这个问题,在一些搜索之后,我发现一个问题在Github中关闭,因此,为了解决这个问题,我必须将typescript版本升级到3.7.2版本。Angular编译器中的错误要求typescript>=3.1.1,我需要在哪个文件中更改它?tsconfig.json文件谢谢。“skipLibCheck”:true(添加到与NestJs相关的Tconfig中),通过nest g ng-app初始化的应用程序与NestJs一起工作。这是一个比升级我们的Typescript版本更好的解决方案。谢谢
"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

  },