title: Angular 5 - 'json does not exist on type Object'
body: <p>I'm following a simple guide and amending it lightly for my needs - But I have finally hit a snag regarding <code>mapping</code> and <code>subscribing</code></p>
  
  <p><a href="https://www.sitepoint.com/mean-stack-angular-2-angular-cli/" rel="nofollow noreferrer">https://www.sitepoint.com/mean-stack-angular-2-angular-cli/</a> - This is the guide and everything is working until I go to build the app after building out the <code>List Service</code>.</p>
  
  <p>I've made a few amendments due to Angular 5 such as replacing with HttpClient, but nothing out of the ordinary.</p>
  
  <p>My present issue falls on these 2 functions:</p>
  
  <pre><code>  public getAllTasks():Observable&lt;Task[]&gt; {
      let URI = `${this.serverApi}/tasks/`;
      return this.http.get(URI)
        .map(res =&gt; res.json())
        .map(res =&gt; &lt;Task[]&gt;res.tasks);
    }
  
  
  
    public deleteTask(taskId : string){
      let URI = `${this.serverApi}/tasks/${taskId}`;
      let headers = new HttpHeaders;
      headers.append('Content-Type', 'application/json');
      return this.http.delete(URI,  {headers})
        .map(res =&gt; res.json());
  
    }
  </code></pre>
  
  <p>Even my IDE tells me that</p>
  
  <pre><code>  .map(res =&gt; res.json())
  </code></pre>
  
  <p>won't work in either function, saying: <code>Property 'json' does not exist on type 'Object'.</code></p>
  
  <p>I've searched around a bit and found some older post with suggestions such as modifying it to be </p>
  
  <pre><code>  .map((res: Response) =&gt; res.json())
  </code></pre>
  
  <p>but that gave me a very similar error </p>
  
  <pre><code>A function whose declared type is neither 'void' nor 'any' must return a value.
  </code></pre>
  
  <p>My model is:</p>
  
  <pre><code>export interface Task {
    _id?: string;
    title: string;
    description: string;
    category: string;
  }
  </code></pre>
  
  <p>Originally this was a class, but I modified it to an interface, as was recommended. I'm unsure if it is related.</p>
  
  <p>Unsure if it's relative, but the component side of it is:</p>
  
  <pre><code> ngOnInit() {
      this.loadTasks();
    }
  
    public loadTasks() {
  
      this.taskServ.getAllTasks().subscribe(
        response =&gt; this.tasks = response,
      )
    }
  </code></pre>
  
  <p>I assume this is some confusion I have with how <code>map</code> works or what it expects. Any input would be appreciated.</p>
  
  <p><strong>Update</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/46630893/angular-4-res-json-is-not-a-function">Angular - res.json() is not a function</a></p>
  
  <p>As mentioned in this post, it seems that HttpClient natively returns the res in JSON, so actually deleting those lines removed the errors. I will post my complete solution once I have it proved out.</p>