Affichage des articles dont le libellé est Defining TypeScript generic type with new(). Afficher tous les articles
Affichage des articles dont le libellé est Defining TypeScript generic type with new(). Afficher tous les articles

samedi 9 janvier 2016

Defining TypeScript generic type with new()

Vote count: 0

I want to have function like:

createEntity<TEntity>(): TEntity {
    return new TEntity();
}

but it doesn't allow to do this. In C# we could write:

void TEntity CreateEntity<TEntity>() where TEntity : new()

How can I do this in TypeScript

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Defining TypeScript generic type with new()