Tôi có hàng ngàn lỗi này sau khi thực hiện lần đầu tiên khi gõ vào terminal ng phục vụ ứng dụng của tôi và tôi không thể giải quyết nó. Đây là lần đầu tiên đối với tôi khi tôi gặp vấn đề như thế này bên trong góc với lỗi bản in trông như thế này:
LRI trong ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:24:19 - lỗi TS1086: Một trình truy cập không thể được khai báo trong ngữ cảnh xung quanh.
24 protected get parentElement(): HTMLElement | null; ~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19
- lỗi TS1086: Một bộ truy cập không thể được khai báo trong ngữ cảnh xung quanh.
26 protected get nativeElement(): HTMLElement; ~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9
- lỗi TS1086: Một bộ truy cập không thể được khai báo trong ngữ cảnh xung quanh.
28 get activatedValue(): string; ~~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9
- lỗi TS1086: Một bộ truy cập không thể được khai báo trong ngữ cảnh xung quanh.
29 set activatedValue(value: string); ~~~~~~~~~~~~~~ ../../node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9
- lỗi TS1086: Một bộ truy cập không thể được khai báo trong ngữ cảnh xung quanh.
[...]
Có ai biết một lý do? Tôi không thể kiểm tra ứng dụng của mình cho đến khi tôi sửa nó.
Cập nhật 1
Được rồi, tôi làm cho nó về phía trước. Hầu hết các lỗi đã biến mất, nhưng bây giờ tôi có một vài lỗi, ví dụ đầu tiên là:
LRI trong src / app / main / main.component.ts: 143: 63 - lỗi TS2322: Nhập 'chuỗi | không xác định 'không thể gán cho kiểu' chuỗi '. Loại 'không xác định' không thể gán cho loại 'chuỗi'.
143 this.fileService.add ({isFolder: true, name: folder.name, Parent: this.cienRoot? This.cienRoot.id: 'root'});
Mã trông như thế này:
main.component.ts:
currentRoot: MpFileElement = new MpFileElement();
...
addFolder(folder: { name: string }) {
this.fileService.add({ isFolder: true, name: folder.name, parent:
this.currentRoot ? this.currentRoot.id : 'root' });
this.updateFileElementQuery();
}
...
file.service.ts:
import { Injectable } from '@angular/core';
import { v4 } from 'uuid';
import { MpFileElement } from '../models/mp-file-element.model';
import { Observable } from 'rxjs/internal/Observable';
import { BehaviorSubject } from 'rxjs';
export interface IFileService {
add(fileElement: MpFileElement);
delete(id: string);
update(id: string, update: Partial<MpFileElement>);
queryInFolder(folderId: string): Observable<MpFileElement[]>;
get(id: string): MpFileElement;
}
@Injectable()
export class MpFileService implements IFileService {
constructor() {}
private map = new Map<string, MpFileElement>()
private querySubject: BehaviorSubject<MpFileElement[]>;
add(fileElement: MpFileElement) {
fileElement.id = v4();
this.map.set(fileElement.id, this.clone(fileElement));
return fileElement;
}
delete(id: string) {
this.map.delete(id);
}
update(id: string, update: Partial<MpFileElement>) {
let element = this.map.get(id);
element = Object.assign(element, update);
this.map.set(element.id, element);
}
queryInFolder(folderId: string) {
const result: MpFileElement[] = [];
this.map.forEach(element => {
if (element.parent === folderId) {
result.push(this.clone(element));
}
})
if (!this.querySubject) {
this.querySubject = new BehaviorSubject(result);
} else {
this.querySubject.next(result);
}
return this.querySubject.asObservable();
}
get(id: string) {
return this.map.get(id);
}
clone(element: MpFileElement) {
return JSON.parse(JSON.stringify(element));
}
}
9.0.0-beta.28
@ angular / flex-layout không? Tôi sẽ thử quay lại phiên bản trước trước khi họ đụng phiên bản TS.