I recently updated my Angular project from version 4 to 5.0 and started encountering an error. The code for the entire project (in Angular 4) can be found on github at https://github.com/SudhirSahoo/IQS
ERROR in src/app/lineside-inspection/lineside-inspection.service.ts(44,9): error TS2322: Type 'Promise<void | LineSideInspection>' is not assigna
ble to type 'Promise<LineSideInspection>'.
Type 'void | LineSideInspection' is not assignable to type 'LineSideInspection'.
Type 'void' is not assignable to type 'LineSideInspection'.
src/app/lineside-inspection/lineside-inspection.service.ts(50,64): error TS2339: Property 'rankAcount' does not exist on type 'Response'.
src/app/lineside-inspection/lineside-inspection.service.ts(51,64): error TS2339: Property 'rankBcount' does not exist on type 'Response'.
src/app/lineside-inspection/lineside-inspec...
<p>Code:</p>
<pre><code>update(inspection: LineSideInspection): Promise<LineSideInspection> {
const url = '/api/inspection/updatecount/';
let rankName = inspection.rankName;
return this.http
.post(url, JSON.stringify(inspection), {headers: this.headers})
.toPromise()
.then(response => {
let data = response.json();
if (rankName='A') inspection.rankAcount = data.rankAcount;
if (rankName='B') inspection.rankBcount = data.rankBcount;
if (rankName='C') inspection.rankCcount = data.rankCcount;
return response.json() as LineSideInspection;
})
.catch(error => {
alert("error");
});
}
If I change the return type to any, then I am not getting that error while ng build.
update(inspection: LineSideInspection): any {
const url = '/api/inspection/updatecount/';
let rankName = inspection.rankName;
return this.http
Do I really have to change the return type everywhere?