我有以下日志记录方法:
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;
}
Run Code Online (Sandbox Code Playgroud)
这requestData是可选的,我希望能够在不发送方法时调用logData而不必指定S类型requestData:而不是:this.logData<T, any>('GET', data),我想调用this.logData<T>('GET', data).有没有办法实现这个目标?