title: Angular 4 RequestOption object not assignable for post method
body: <p>I'm trouble with these codes, I created a header with following code block</p>
  
  <pre><code>headers.append("Authorization",btoa(username+":"+password));
  
  var requestOptions = new RequestOptions({headers:headers});
  </code></pre>
  
  <p>But if I try use this in a post method in that</p>
  
  <pre><code>return this.http.post(url,JSON.stringify({username,password}),requestOptions)
      .map(res=&gt;res.json())
      .map(res=&gt;{
        if(res){
          localStorage.setItem("isLogged",res);
          this.loggedIn =true;
        }
        return res;
      });
  </code></pre>
  
  <p>I take this error message</p>
  
  <pre><code>Typescript Error
  Argument of type 'RequestOptions' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'. Types of property 'headers' are incompatible. Type 'Headers' is not assignable to type 'HttpHeaders | { [header: string]: string | string[]; }'. Type 'Headers' is not assignable to type '{ [header: string]: string | string[]; }'. Index signature is missing in type 'Headers'.
  </code></pre>
  
  <p>I tried change Header() to HttpHeader() but it didn't help. What is the problem?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>I removed requestOptions object then I created headers from HttpHeaders()</p>
  
  <pre><code>let headers = new HttpHeaders();
  </code></pre>
  
  <p>and use this headers value in post method in that</p>
  
  <pre><code>return this.http.post(url,JSON.stringify({username,password}), { options: { headers: headers; } })
      .map(res=&gt;res.json())
      .map(res=&gt;{
        if(res){
          localStorage.setItem("isLogged",res);
          this.loggedIn =true;
        }
        return res;
      });
  </code></pre>
  
  <p>then get this error</p>
  
  <pre><code>[ts]
  Argument of type '{ options: { headers: HttpHeaders; }; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'.
    Object literal may only specify known properties, and 'options' does not exist in type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'.
  </code></pre>
  
  <p>I also tried this</p>
  
  <pre><code>return this.http.post(url,JSON.stringify({username,password}), { headers: headers })
      .map(res=&gt;res.json())
      .map(res=&gt;{
        if(res){
          localStorage.setItem("isLogged",res);
          this.loggedIn =true;
        }
        return res;
      });
  </code></pre>
  
  <p>then I got an error on first ".map"</p>
  
  <pre><code>[ts] Property 'map' does not exist on type 'Observable&lt;Object&gt;'.
  </code></pre>