{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-decorators/issues/2","repository_url":"https://api.github.com/repos/tc39/proposal-decorators","labels_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/2/comments","events_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/2/events","html_url":"https://github.com/tc39/proposal-decorators/issues/2","id":159732376,"number":2,"title":"Use case: class/function registration","user":{"login":"justinfagnani","id":522948,"avatar_url":"https://avatars.githubusercontent.com/u/522948?v=3","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-10T22:04:37Z","updated_at":"2016-06-11T00:30:23Z","closed_at":null,"body":"Registering classes/functions could often invoke a registration function at class definition time, but not modify the object, such as with web components:\r\n\r\n```javascript\r\nfunction define(tagname) {\r\n  return (clazz) => {\r\n    customElements.define(tagname, clazz);\r\n    return clazz;\r\n  };\r\n}\r\n\r\n@define('my-element')\r\nclass MyElement extends HTMLElement {}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/tc39/proposal-decorators/issues/comments/225325229","html_url":"https://github.com/tc39/proposal-decorators/issues/2#issuecomment-225325229","issue_url":"https://api.github.com/repos/tc39/proposal-decorators/issues/2","id":225325229,"user":{"login":"justinfagnani","id":522948,"avatar_url":"https://avatars.githubusercontent.com/u/522948?v=3","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"created_at":"2016-06-11T00:30:23Z","updated_at":"2016-06-11T00:30:23Z","body":"Yes, a static analysis tool would have to know about the decorator, but decorator syntax is _much_ more amenable to analysis. So the Polymer Analyzer, which looks for element declarations, need only look for class declarations decorated with `@define`, rather than try to look for calls to `customElements.define`, which may be called from another function.\r\n\r\nYour example of composing decorator functions would fool most static analysis. In my experience with very similar metadata annotations in other languages, `@foo` is more likely to be directly used in a manner that can be detected."}}
{"actor":{"display_login":"justinfagnani"}}