Typescript:Argument of type '{headers: Headers;}' is not assignable to parameter of type 'RequestOptionsArgs'.

代码:

update(hero: Hero): Promise {
  const url = `${this.heroesUrl}/${hero.id}`;
  return this.http
    .put(url, JSON.stringify(hero), {headers: this.headers})
    .toPromise()
    .then(() => hero)
    .catch(this.handleError);
}

报错:

Argument of type '{ headers: Headers; }' is not assignable to parameter of type 'RequestOptionsArgs'. Types of property 'headers' are incompatible. Type 'Headers' is not assignable to type 'Headers'. Two different types with this name exist, but they are unrelated. Property 'keys' is missing in type 'Headers'.

解决:

update(hero: Hero): Promise {
  const url = `${this.heroesUrl}/${hero.id}`;
  return this.http
    .put(url, JSON.stringify(hero), {headers: this.headers} **as RequestOptionsArgs**)
    .toPromise()
    .then(() => hero)
    .catch(this.handleError);
}