title: TS1086: An accessor cannot be declared in ambient context
body: <p>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:</p>
  
  <blockquote>
    <p>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.</p>
  
  <pre><code>24     protected get parentElement(): HTMLElement | null;
                       ~~~~~~~~~~~~~
  ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:26:19
  </code></pre>
    
    <p>- error TS1086: An accessor cannot be declared in an ambient context.</p>
  
  <pre><code>26     protected get nativeElement(): HTMLElement;
                       ~~~~~~~~~~~~~
  ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:28:9
  </code></pre>
    
    <p>- error TS1086: An accessor cannot be declared in an ambient context.</p>
  
  <pre><code>28     get activatedValue(): string;
             ~~~~~~~~~~~~~~
  ../../node_modules/@angular/flex-layout/core/typings/base/base2.d.ts:29:9
  </code></pre>
    
    <p>- error TS1086: An accessor cannot be declared in an ambient context.</p>
  
  <pre><code>29     set activatedValue(value: string);
             ~~~~~~~~~~~~~~
  ../../node_modules/@angular/flex-layout/core/typings/breakpoints/break-point-registry.d.ts:20:9
  </code></pre>
    
    <p>- error TS1086: An accessor cannot be declared in an ambient context.
        <code>[...]</code></p>
  </blockquote>
  
  <p>Does somebody know a reason? I can't test my app until I fix it.</p>
  
  <h1>Update 1</h1>
  
  <p>Okay, i make it forward. Most of errors is gone, but i have few ones now, for example first of them:</p>
  
  <blockquote>
    <p>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'.</p>
    
    <p>143     this.fileService.add({ isFolder: true, name: folder.name,
    parent: this.currentRoot ? this.currentRoot.id : 'root' });</p>
  </blockquote>
  
  <p>Code looks like this:</p>
  
  <p>main.component.ts:</p>
  
  <pre><code>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();
      }
  ...
  </code></pre>
  
  <p>file.service.ts:</p>
  
  <pre><code>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&lt;MpFileElement&gt;);
      queryInFolder(folderId: string): Observable&lt;MpFileElement[]&gt;;
      get(id: string): MpFileElement;
  }
  
  @Injectable()
  export class MpFileService implements IFileService {
  
      constructor() {}
      private map = new Map&lt;string, MpFileElement&gt;()
  
      private querySubject: BehaviorSubject&lt;MpFileElement[]&gt;;
  
      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&lt;MpFileElement&gt;) {
          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 =&gt; {
              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));
      }
  }
  </code></pre>