Answers for "Generic constraint on constructor function"

0

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);
Posted by: Guest on October-18-2020

Code answers related to "Generic constraint on constructor function"

Browse Popular Code Answers by Language