How can I make a generic type optional?

As of TypeScript 2.3, you can use generic parameter defaults.

private logData<T, S = {}>(operation: string, responseData: T, requestData?: S) {
  // your implementation here
}

Leave a Comment