{"action":"created","issue":{"url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/544","repository_url":"https://api.github.com/repos/dcodeIO/protobuf.js","labels_url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/544/labels{/name}","comments_url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/544/comments","events_url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/544/events","html_url":"https://github.com/dcodeIO/protobuf.js/issues/544","id":194860947,"number":544,"title":"TypeScript: strongly typed lookup function","user":{"login":"paralin","id":534887,"avatar_url":"https://avatars.githubusercontent.com/u/534887?v=3","gravatar_id":"","url":"https://api.github.com/users/paralin","html_url":"https://github.com/paralin","followers_url":"https://api.github.com/users/paralin/followers","following_url":"https://api.github.com/users/paralin/following{/other_user}","gists_url":"https://api.github.com/users/paralin/gists{/gist_id}","starred_url":"https://api.github.com/users/paralin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paralin/subscriptions","organizations_url":"https://api.github.com/users/paralin/orgs","repos_url":"https://api.github.com/users/paralin/repos","events_url":"https://api.github.com/users/paralin/events{/privacy}","received_events_url":"https://api.github.com/users/paralin/received_events","type":"User","site_admin":false},"labels":[{"id":34431431,"url":"https://api.github.com/repos/dcodeIO/protobuf.js/labels/compatibility","name":"compatibility","color":"e102d8","default":false},{"id":30280644,"url":"https://api.github.com/repos/dcodeIO/protobuf.js/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-12-11T22:18:45Z","updated_at":"2016-12-15T13:06:38Z","closed_at":"2016-12-15T13:06:38Z","body":"I'm finding myself doing this a lot:\r\n\r\n```js\r\n(<any>tree.lookup('mynamespace.MyMessage')).encode...\r\n```\r\n\r\nThe reason is that `lookup` returns a `ReflectionObject` which I cannot directly cast to any of its children (I can cast a Type -> ReflectionObject but not the other way around). \r\n\r\nI'm proposing doing something like:\r\n\r\n```js\r\ntree.lookupService('mynamespace.MyService'); // ok -> ProtoBuf.Service\r\ntree.lookupType('mynamespace.MyService'); // throws -> MyService is not a Type\r\n```\r\n\r\nStrongly typed with exceptions if you attempt to lookup the wrong type (or just return null)"},"comment":{"url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/comments/267323046","html_url":"https://github.com/dcodeIO/protobuf.js/issues/544#issuecomment-267323046","issue_url":"https://api.github.com/repos/dcodeIO/protobuf.js/issues/544","id":267323046,"user":{"login":"dcodeIO","id":1136893,"avatar_url":"https://avatars.githubusercontent.com/u/1136893?v=3","gravatar_id":"","url":"https://api.github.com/users/dcodeIO","html_url":"https://github.com/dcodeIO","followers_url":"https://api.github.com/users/dcodeIO/followers","following_url":"https://api.github.com/users/dcodeIO/following{/other_user}","gists_url":"https://api.github.com/users/dcodeIO/gists{/gist_id}","starred_url":"https://api.github.com/users/dcodeIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcodeIO/subscriptions","organizations_url":"https://api.github.com/users/dcodeIO/orgs","repos_url":"https://api.github.com/users/dcodeIO/repos","events_url":"https://api.github.com/users/dcodeIO/events{/privacy}","received_events_url":"https://api.github.com/users/dcodeIO/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T13:06:38Z","updated_at":"2016-12-15T13:06:38Z","body":"`lookupType` and `lookupService` are now generated programmatically, which makes me feel a lot better about this. Considering this issue fixed for now."}}
{"actor":{"display_login":"dcodeIO"}}