I just start to learn angular and I found my company project has the following code:
currentCDFlow: CDCurrentFlowDTO;
this.currentCDFlow = await this.serivce.getCDMaster();
and the getCDMaster() code is
public async getCDMaster(): Promise<CDCurrentFlowDTO> {
return await this.http.post<CDCurrentFlowDTO>(Constants.BASE_HREF + '/getCDMaster', null, this.RequestJson).toPromise().catch(err => { throw err });
}
as getCDMaster() is returning Promise<CDCurrentFlowDTO>
(a Promise object), why it can assign to object of CDCurrentFlowDTO? I expect it can only assign to object of Promise<CDCurrentFlowDTO>
, but not just CDCurrentFlowDTO
(without enclosed by Promise<...>).
As in java,
String a = new ArrayList<String>();
should have compile error...
Is this typescript feature?