As of TypeScript 2.3, you can use generic parameter defaults.
private logData<T, S = {}>(operation: string, responseData: T, requestData?: S) {
// your implementation here
}
More Related Contents:
- TypeScript: self-referencing return type for static methods in inheriting classes
- Why doesn’t the example compile, aka how does (co-, contra-, and in-) variance work?
- How do I use integer number literals when using generic types?
- TypeScript how to create a generic type alias for a generic function?
- How do I write the lifetimes for references in a type constraint when one of them is a local reference?
- Typescript, merge object types?
- In TypeScript, how to get the keys of an object type whose values are of a given type?
- Why does a generic method inside a trait require trait object to be sized?
- Higher-order type functions in TypeScript?
- C# Adding two Generic Values
- Matching a generic parameter to an associated type in an impl
- Generic Functions in Go
- Generic repository in ASP.NET Core without having a separate AddScoped line per table in Startup.cs?
- Why can’t `&(?Sized + Trait)` be cast to `&dyn Trait`?
- Typescript ReturnType of generic function
- Workaround for accessing class type arguments in static method in Typescript
- Why can’t I add a blanket impl on a trait with a type parameter?
- What does the question mark mean in a type parameter bound?
- How to determine if a generic is an optional in Swift?
- Calling a static method from a generic constraint Dart
- Generic NSOperation subclass loses NSOperation functionality
- Iterable cannot confirm generic T in function
- Extension of constructed generic type in Swift
- How to get actual type arguments of a reified generic parameter in Kotlin?
- What does it mean to instantiate a Rust generic with an underscore?
- Does F# have generic arithmetic support?
- Unable to create a polymorphic type because the trait cannot be made into an object
- What is the cited problem with using generic type parameters in trait objects?
- How to call a named constructor from a generic function in Dart/Flutter
- Returning original collection type in generic method