TypeScript · Senior · Question 40 of 75
How do you type a parameter that accepts an abstract class constructor?
- ✓Correct answer:
abstract new (...args: any[]) => T - 2
typeof T - 3
Constructor<T>from the standard library
Explanation
Abstract construct signatures (TS 4.2) let you accept both abstract and regular classes - e.g. in mixin functions. new (...args) => T won't accept an abstract class. There's no built-in Constructor<T>; people usually declare it themselves.