I'm looking to create an object based on a generic type, but can't figure out the syntax. What I'm wanting is something like this contrived example:
myfunc<T>() : T[] {
let obj = new T();
let obj2 = new T();
return [obj, obj2];
}
The new T()
of course doesn't compile. In C# I'd add a where T : new
constraint to make that work. What's the equivalent in TypeScript?