TS1086: An accessor cannot be declared in an ambient context

后端 未结 2 883
庸人自扰
庸人自扰 2021-01-22 04:57

When running with Angular, I\'m getting thje error TS1086: An accessor cannot be declared in an ambient context. for Javascript getters and setters in this Abstract

2条回答
  •  执念已碎
    2021-01-22 05:52

    This isn't an Angular error.

    TypeScript 3.7 introduced a breaking change for getters and setters in the type definition files.

    As mentioned above, TypeScript 3.7 emits get/set accessors in .d.ts files which can cause breaking changes for consumers on older versions of TypeScript like 3.5 and prior. TypeScript 3.6 users will not be impacted, since that version was future-proofed for this feature.

    https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#class-field-mitigations

    You should be using TypeScript 3.6 or higher if you're going to consume type definitions generated with 3.7 or higher.

提交回复
热议问题