{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3628","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3628/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3628/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3628/events","html_url":"https://github.com/Microsoft/TypeScript/issues/3628","id":90896359,"number":3628,"title":"Discussion: (Reflective) Type Model","user":{"login":"christyharagan","id":825421,"avatar_url":"https://avatars.githubusercontent.com/u/825421?v=3","gravatar_id":"","url":"https://api.github.com/users/christyharagan","html_url":"https://github.com/christyharagan","followers_url":"https://api.github.com/users/christyharagan/followers","following_url":"https://api.github.com/users/christyharagan/following{/other_user}","gists_url":"https://api.github.com/users/christyharagan/gists{/gist_id}","starred_url":"https://api.github.com/users/christyharagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christyharagan/subscriptions","organizations_url":"https://api.github.com/users/christyharagan/orgs","repos_url":"https://api.github.com/users/christyharagan/repos","events_url":"https://api.github.com/users/christyharagan/events{/privacy}","received_events_url":"https://api.github.com/users/christyharagan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Needs%20More%20Info","name":"Needs More Info","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-25T08:40:13Z","updated_at":"2015-08-16T09:25:05Z","closed_at":null,"body":"Hi all,\r\n\r\nWe currently have a AST model for TypeScript which is useful for compilers, editors, and linters.\r\n\r\nHowever, it would be extremely useful to have a type model, a la Java's reflective model. There are a huge number of use-cases supporting this, but I will list a few here:\r\n\r\n - I have a REST interface and I define a data model for it as a TypeScript interface. I use this interface for the function definition of the REST implementation, but then use the type model to validate the input at runtime.\r\n\r\n - I have a service model that abstracts an interface for some system (database, or application, etc.). I define this as a TypeScript interface (maybe with some decorators as meta-data), and have a generator library that extracts this information to either generate code - or create a runtime implementation - that actually implements the service.\r\n\r\n - I have an injection (DI) system. I use injection decorators on class properties/constructor parameters, and use the type model to reflectively wire the correct instance.\r\n\r\nA good example of what could be achieved with this, is something like the Spring platform for Java where our applications are built as decorated components and most of the boilerplate code is abstracted away by the platform thanks to reflection and decorators.\r\n\r\n\r\nI have a \"first stab\" at implementing such a thing: [typescript-schema](https://github.com/christyharagan/ts-schema). It's not feature complete and the design isn't finished either. But hopefully it gives a feel for what a reflective model could look like.\r\n\r\nIs this something the TypeScript team would be interested in having as a first class citizen?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/131509171","html_url":"https://github.com/Microsoft/TypeScript/issues/3628#issuecomment-131509171","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3628","id":131509171,"user":{"login":"tobich","id":1175842,"avatar_url":"https://avatars.githubusercontent.com/u/1175842?v=3","gravatar_id":"","url":"https://api.github.com/users/tobich","html_url":"https://github.com/tobich","followers_url":"https://api.github.com/users/tobich/followers","following_url":"https://api.github.com/users/tobich/following{/other_user}","gists_url":"https://api.github.com/users/tobich/gists{/gist_id}","starred_url":"https://api.github.com/users/tobich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobich/subscriptions","organizations_url":"https://api.github.com/users/tobich/orgs","repos_url":"https://api.github.com/users/tobich/repos","events_url":"https://api.github.com/users/tobich/events{/privacy}","received_events_url":"https://api.github.com/users/tobich/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T09:25:05Z","updated_at":"2015-08-16T09:25:05Z","body":"@danquirk So when @jonathandturner said at http://blogs.msdn.com/b/typescript/archive/2015/03/05/angular-2-0-built-on-typescript.aspx\r\n> We've also added a way to retrieve type information at runtime.  When enabled, this will enable developers to do a simple type introspection.\r\n\r\nhe meant metadata generated only for decorators, not full-scale reflection (for all public symbols, for example)?"}}