Open this example in the interactive library
Source code
interface Named {
name: string;
}
console.log(
(<T,>(Ctor: new () => T) => new Ctor())(
class {
ready = true;
},
),
);
Sample output
{ ready: true }
Construct an instance from a typed constructor using TypeScript.
Open this example in the interactive library
interface Named {
name: string;
}
console.log(
(<T,>(Ctor: new () => T) => new Ctor())(
class {
ready = true;
},
),
);
{ ready: true }