Defining typescript generics with type safety

generics, typescript

Solution

Ok it seems you can do this:

Foo<T extends IBar>() { /* */ }

And that seems to make all calls require the T to implement `IBar`.

Problem

Can you define generics with safe types, as you can with c#? E.g. ``` public bool Foo<T>() where T : struct { /* */ } ``` Typescript now has generics, but can I perform a similar action? Thanks.

Original source