在初始实施后,我在终端 ng serve my-app of 中输入了数千个此错误,但我无法解决它。这对我来说是第一次,当我在 angular 内部遇到这样的问题时,打字稿错误看起来像这样:
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:24:19 中的错误 - 错误 TS1086:无法在环境上下文中声明访问器。
Run Code Online (Sandbox Code Playgroud)24 protected get parentElement(): HTMLElement | null; ~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19- 错误 TS1086:无法在环境上下文中声明访问器。
Run Code Online (Sandbox Code Playgroud)26 protected get nativeElement(): HTMLElement; ~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9- 错误 TS1086:无法在环境上下文中声明访问器。
Run Code Online (Sandbox Code Playgroud)28 get activatedValue(): string; ~~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9- 错误 TS1086:无法在环境上下文中声明访问器。
Run Code Online (Sandbox Code Playgroud)29 set activatedValue(value: string); ~~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9- 错误 TS1086:无法在环境上下文中声明访问器。
[...]
有人知道原因吗?在我修复它之前,我无法测试我的应用程序。
好的,我继续前进。大多数错误都消失了,但我现在有几个错误,例如第一个:
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)