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()

Aucun commentaire:

Enregistrer un commentaire