js add restriction to constructor parameter code example
Example 1: Generic constraint on constructor function
function createInstance<T>(t: new () => T): T {
return new t();
}
class Test {
x: number = 4;
}
let test: Test = createInstance(Test);
console.log(test);
Example 2: how to create class in javascript
class ClassName
{
}