我正在尝试将 Angular 9 应用程序更新为 Angular 10 并出现错误:
> Removing "Solution Style" TypeScript configuration file support.
× Migration failed: Failed to parse "tsconfig.json" as JSON AST Object. PropertyNameExpected at location: 571.
See "C:\Users\F11K\AppData\Local\Temp\ng-T8Bgiu\angular-errors.log" for further details.
Run Code Online (Sandbox Code Playgroud)
这是日志文件的内容:
[error] Error: Failed to parse "tsconfig.json" as JSON AST Object. PropertyNameExpected at location: 571.
at JSONFile.get JsonAst [as JsonAst] (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:33:19)
at JSONFile.get (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:41:61)
at C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\migrations\update-10\remove-solution-style-tsconfig.js:33:71
at MergeMapSubscriber.project (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\rules\call.js:75:24)
at MergeMapSubscriber._tryNext (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
at MergeMapSubscriber._next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
at MergeMapSubscriber.Subscriber.next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Subscriber.js:66:18)
at Observable._subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
at Observable._trySubscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:44:25)
at …
Run Code Online (Sandbox Code Playgroud) 我有一个带有我自己的自定义控件组件的表单:
@Component({
selector: "my-app",
template: `
<form [formGroup]="form">
<app-custom-control formControlName="customControl"></app-custom-control>
</form>
<button (click)="touch()">
Touch!
</button>
`,
styleUrls: ["./app.component.css"]
})
export class AppComponent {
form: FormGroup;
constructor(private fb: FormBuilder) {}
ngOnInit() {
this.form = this.fb.group({
customControl: "1"
});
}
touch() {
this.form.markAllAsTouched();
}
}
Run Code Online (Sandbox Code Playgroud)
我的自定义控制组件内部又包含另一个自定义控制组件(在我的真实应用程序中需要它,因为外部控制组件有两种模式 - 读取和编辑):
@Component({
selector: "app-custom-control",
template: `
<ng-select [ngModel]="value" [items]="items"></ng-select>
`,
styleUrls: ["./custom-control.component.css"],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: CustomControlComponent,
multi: true
}
]
})
export class CustomControlComponent implements ControlValueAccessor, OnInit {
items = ["1", "2"]; …
Run Code Online (Sandbox Code Playgroud)