I have a thousands of this error after initial implementation nad typing in terminal ng serve my-app of and i can't resolve it. This is first time for me when i have problem like this inside angular with typescript
Errors looks like this:
ERROR in
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:24:19
- error TS1086: An accessor cannot be declared in an ambient context.
24 protected get parentElement(): HTMLElement | null;
~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19
- error TS1086: An accessor cannot be declared in an ambient context.
26 protected get nativeElement(): HTMLElement;
~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9
- error TS1086: An accessor cannot be declared in an ambient context.
28 get activatedValue(): string;
~~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9
- error TS1086: An accessor cannot be declared in an ambient context.
29 set activatedValue(value: string);
~~~~~~~~~~~~~~
../../node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9
- error TS1086: An accessor cannot be declared in an ambient context.
[...]
Does somebody know a reason? I can't test my app until I fix it.
Update 1
Okay, i make it forward. Most of errors is gone, but i have few ones now, for example first of them:
ERROR in src/app/main/main.component.ts:143:63 - error TS2322: Type
'string | undefined' is not assignable to type 'string'. Type
'undefined' is not assignable to type 'string'.
143 this.fileService.add({ isFolder: true, name: folder.name,
parent: this.currentRoot ? this.currentRoot.id : 'root' });
Code looks like this:
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));
}
}
See Question&Answers more detail:
os