Hi all, Sorry for posting here but there doesn’t seem to be a Typescript forum yet.
I have bought the Typescript course and tried to consume the generics section, but I still can’t quite figure this out.
I would like to do the typescript equivalent of this c# code - more specifically the getPage method using generics. Any help appreciated, especially with a comment explaining the solution
class Pages
{
private static T GetPage<T>() where T : new()
{
var page = new T();
return page;
}
public static AboutPage About
{
get { return GetPage<AboutPage>(); }
}
}
I would also need the ‘page = new’ bit to take an argument as well.