@Types/Sequelize Error TS1086: An accessor cannot be declared in ambient context

孤人 提交于 2019-12-18 09:00:56

问题


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;
         ~~~~

My versions are:

  • "@types/sequelize": "^4.28.6"
  • "sequelize": "^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?

Thanks.


回答1:


you need to use 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.

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.



来源:https://stackoverflow.com/questions/58802463/types-sequelize-error-ts1086-an-accessor-cannot-be-declared-in-ambient-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!