Advertisement
Suchiman

Untitled

Jul 14th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. Working C# equivalent:
  2. public class BaseInterface
  3. {
  4.     public string Name { get; set; }
  5. }
  6.  
  7. public T getMeObject<T>() where T : BaseInterface, new()
  8. {
  9.     return new T { Name = "WUT" };
  10. }
  11.  
  12. Not working Typescript:
  13. interface BaseInterface {
  14.     Name: string;
  15. }
  16.  
  17. function getMeObject<T extends BaseInterface>(): T {
  18.     // {...} cannot be converted into T
  19.     return {
  20.         Name: "omg"
  21.     };
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement