I have the following logging method:
private logData<T, S>(operation: string, responseData: T, requestData?: S) {
this.logger.log(operation + ' ' + this.url);
if (requestData) {
this.logger.log('SENT');
this.logger.log(requestData);
}
this.logger.log('RECEIVED');
this.logger.log(responseData);
return responseData;
}
The requestData
is optional, I want to be able to call logData
without having to specify the S
type when I don't send the requestData
to the method: instead of: this.logData<T, any>('GET', data)
, I want to call this.logData<T>('GET', data)
.
Is there a way to achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…