I just made two important upgrades to our Angular 4 application and build tools:
- @angular/core
^4.1.3
=> ^4.2.4
(and /http, /forms, etc)
- tslint
^5.3.2
=> ^5.4.3
I have a Service which declares options like so:
@Injectable()
export class WorkOrderService {
private headers: Headers = new Headers({ 'Content-Type': 'application/json' });
private options: RequestOptions = new RequestOptions(this.headers);
constructor(private http: Http) {}
/* Methods ... */
}
The above now no longer validates tslint, throwing the following error:
error TS2559: Type 'Headers' has no properties in common with type 'RequestOptionsArgs'.
The source (@angular/http interface.d.ts:43
) clearly allows for Headers
as a RequestOptionsArgs
:
/**
* Interface for options to construct a RequestOptions, based on
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
*
* @experimental
*/
export interface RequestOptionsArgs {
url?: string | null;
method?: string | RequestMethod | null;
/** @deprecated from 4.0.0. Use params instead. */
search?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
params?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
headers?: Headers | null;
body?: any;
withCredentials?: boolean | null;
responseType?: ResponseContentType | null;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…