TypeScript · Middle · Question 63 of 75
How do you get the instance type and constructor arguments of a class?
type Svc = InstanceType<typeof ApiService>;
type Args = ConstructorParameters<typeof ApiService>;- ✓Correct answer: With
InstanceTypeandConstructorParametersapplied totypeof Class - 2With
ReturnType<ApiService> - 3Classes can't be used in type operators
Explanation
ApiService as a type already means the instance type; typeof ApiService is the constructor itself.