下面的代码在Typescript 2.1.6中工作正常
public update(payload: VersionedDataTransferObject): Promise<Response<DsbMannschaftDO>>{
// return promise
// sign in success -> resolve promise
// sign in failure -> reject promise with result
return new Promise((resolve, reject) => {
this.restClient.PUT<VersionedDataTransferObject>(new UriBuilder().fromPath(this.getUrl()).build(), payload)
.then((data: VersionedDataTransferObject) => {
resolve({result: RequestResult.SUCCESS, payload: fromPayload(data)});
}, (error: HttpErrorResponse) => {
if (error.status === 0) {
reject({result: RequestResult.CONNECTION_PROBLEM});
} else {
reject({result: RequestResult.FAILURE});
}
});
});
}
更新打字稿后。我收到以下错误消息:
错误TS2345:类型为“ {结果:RequestResult.SUCCESS; 有效负载:DsbMannschaftDTO; }'不能分配给类型的参数 '响应| PromiseLike>'。