Incorporating TypeScript 3.7, I created an interface featuring a property designed to accept a constructor function:
interface IConstruct<T> {
type: new (...args:ConstructorParameters<T>) => T;
}
I initially assumed that IConstruct<User>
would include a property {type: User}
.
However, the compiler is indicating that T
cannot be utilized in this context. What is the reason for this error message?
TS2344: Type T does not satisfy the constraint 'new (...args: any) => any'