{"action":"closed","issue":{"url":"https://api.github.com/repos/weichx/cerialize/issues/9","repository_url":"https://api.github.com/repos/weichx/cerialize","labels_url":"https://api.github.com/repos/weichx/cerialize/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/weichx/cerialize/issues/9/comments","events_url":"https://api.github.com/repos/weichx/cerialize/issues/9/events","html_url":"https://github.com/weichx/cerialize/issues/9","id":123911746,"number":9,"title":"Support type parameterized `Deserialize` function ","user":{"login":"1ambda","id":4968473,"avatar_url":"https://avatars.githubusercontent.com/u/4968473?v=3","gravatar_id":"","url":"https://api.github.com/users/1ambda","html_url":"https://github.com/1ambda","followers_url":"https://api.github.com/users/1ambda/followers","following_url":"https://api.github.com/users/1ambda/following{/other_user}","gists_url":"https://api.github.com/users/1ambda/gists{/gist_id}","starred_url":"https://api.github.com/users/1ambda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1ambda/subscriptions","organizations_url":"https://api.github.com/users/1ambda/orgs","repos_url":"https://api.github.com/users/1ambda/repos","events_url":"https://api.github.com/users/1ambda/events{/privacy}","received_events_url":"https://api.github.com/users/1ambda/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-12-26T06:16:20Z","updated_at":"2016-05-05T14:47:50Z","closed_at":"2016-05-05T14:47:50Z","body":"I am writing `Dserializable` abstract class which indicate it can be **deserialized** and has `deserialize` Function. It looks like\r\n\r\n```typescript\r\nconst cerialize = require('cerialize'); // import\r\n\r\nabstract class Deserializable {\r\n  public static deserialize<T> (json, constructor): T {\r\n    return cerialize.Deserialize(json, constructor);\r\n  }\r\n}\r\n\r\n// usage\r\nclass Command extends Deserializable {\r\n  @deserialize public help: boolean;\r\n  @deserializeAs(CommandOrder, \"_order\") public orders: Array<CommandOrder>;\r\n  @deserializeAs(\"_args\") public args: Array<String>;\r\n}\r\n\r\nlet cmd = Command.deserialize<Command>(json, Command);\r\n```\r\n\r\nBut since [`cerialize.Deserialize`](https://github.com/weichx/cerialize/blob/87fe32f40e29abb97055e8f6b79be13fc73c597c/src/serialize.ts#L404) requires the constructor function as the second arg, It's somewhat verbose. \r\n\r\nIf we have a type parameterized `cerialize.Deserialize` function, we can make more simplified  `Deserialzable`. For example,\r\n\r\n```typescript\r\nexport abstract class Deserializable {\r\n  public static deserialize<T> (json): T {\r\n    return Deserialize<T>(json);\r\n  }\r\n}\r\n\r\n// more simple\r\nCommand.deserialize<Command>(json);\r\n```\r\n\r\nThanks. :)"}}