I encountered new()
in the official document here about generics.
Here is the code context:
function create<T>(c: { new(): T; } ): T {
return new c();
}
The above code is transpiled to the following JavaScript code:
function create(c) {
return new c();
}
new()
is illegal syntax in JavaScript. What does it mean in TypeScript?
Furthermore, what does {new(): T; }
mean? I know it must be a type, but how?