InstanceType<T>
The utility type that gives the type of object produced by calling new on class type T.
In more detail
InstanceType<typeof PaymentService> is PaymentService. It lets a factory that receives a class return a correctly typed instance.
Related terms
- ConstructorParameters<T> — The utility type that gives a class constructor's parameter list as a tuple.
- factory function — A function whose job is to create and return new objects, often choosing or configuring the class to use.
- class — A blueprint in code that bundles data and the functions that work on it, from which objects are made.
Taught in
- Function Utilities: ReturnType, Parameters And Constructor — Production TypeScript