小编xav*_*mpt的帖子

TS1086:不能在环境上下文中声明访问器

在初始实施后,我在终端 ng serve my-app of 中输入了数千个此错误,但我无法解决它。这对我来说是第一次,当我在 angular 内部遇到这样的问题时,打字稿错误看起来像这样:

../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:24:19 中的错误 - 错误 TS1086:无法在环境上下文中声明访问器。

24     protected get parentElement(): HTMLElement | null;
                     ~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19
Run Code Online (Sandbox Code Playgroud)

- 错误 TS1086:无法在环境上下文中声明访问器。

26     protected get nativeElement(): HTMLElement;
                     ~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9
Run Code Online (Sandbox Code Playgroud)

- 错误 TS1086:无法在环境上下文中声明访问器。

28     get activatedValue(): string;
           ~~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9
Run Code Online (Sandbox Code Playgroud)

- 错误 TS1086:无法在环境上下文中声明访问器。

29     set activatedValue(value: string);
           ~~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9
Run Code Online (Sandbox Code Playgroud)

- 错误 TS1086:无法在环境上下文中声明访问器。 [...]

有人知道原因吗?在我修复它之前,我无法测试我的应用程序。

更新 1

好的,我继续前进。大多数错误都消失了,但我现在有几个错误,例如第一个:

src/app/main/main.component.ts:143:63 中的错误 - 错误 TS2322:键入 'string | undefined' 不能分配给类型 'string'。类型 'undefined' 不能分配给类型 'string'。

第 143 章

代码如下所示:

main.component.ts:

currentRoot: MpFileElement = new …
Run Code Online (Sandbox Code Playgroud)

typescript angular

87
推荐指数
6
解决办法
16万
查看次数

标签 统计

angular ×1

typescript ×1