@Types/Sequelize 错误 TS1086:无法在环境上下文中声明访问器 [英] @Types/Sequelize Error TS1086: An accessor cannot be declared in ambient context

查看:16
本文介绍了@Types/Sequelize 错误 TS1086:无法在环境上下文中声明访问器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目在运行tsc"时显示此错误:

I have a project that shows this error when I run '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"
  • "sequelize-typescript": "1.0.0-beta.4"

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

The project works fine with nodemon but fails when I try to compile the typescript. Anyone knows this error?

谢谢.

推荐答案

你需要使用typescript 3.7.

you need to use typescript 3.7.

来自 typescript 3.7 发行说明:

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.

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.

这篇关于@Types/Sequelize 错误 TS1086:无法在环境上下文中声明访问器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆