当使用Angular运行时,在这个Abstract Typescript类中,我遇到TS1086: An accessor cannot be declared in an ambient context.
了Java语言getter和setter的错误。
这是来源:
/**
* The current id key for the EStore instance.
* @return this.config.idKey;
*/
get ID_KEY(): string {
return this.config.idKey
}
/**
* The current guid key for the EStore instance.
* @return this.config.guidKey;
*/
get GUID_KEY(): string {
return this.config.guidKey
}
直到最新版本的Angular都可以正常工作。我们是否不再被允许在Abstract类中使用getter和setter?
这不是Angular错误。
TypeScript 3.7对类型定义文件中的getter和setter进行了重大更改。
如上所述,TypeScript 3.7在.d.ts文件中发出get / set访问器,这可能导致使用方TypeScript(如3.5及更早版本)的使用者发生重大更改。TypeScript 3.6用户将不会受到影响,因为该功能已针对该版本进行了过时验证。
如果要使用3.7或更高版本生成的类型定义,则应该使用TypeScript 3.6或更高版本。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句