{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/175","labels_url":"https://api.github.com/repos/facebook/flow/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/175/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/175/events","html_url":"https://github.com/facebook/flow/issues/175","id":51213325,"number":175,"title":"Aliasing inferred types","user":{"login":"jareware","id":560055,"avatar_url":"https://avatars.githubusercontent.com/u/560055?v=3","gravatar_id":"","url":"https://api.github.com/users/jareware","html_url":"https://github.com/jareware","followers_url":"https://api.github.com/users/jareware/followers","following_url":"https://api.github.com/users/jareware/following{/other_user}","gists_url":"https://api.github.com/users/jareware/gists{/gist_id}","starred_url":"https://api.github.com/users/jareware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jareware/subscriptions","organizations_url":"https://api.github.com/users/jareware/orgs","repos_url":"https://api.github.com/users/jareware/repos","events_url":"https://api.github.com/users/jareware/events{/privacy}","received_events_url":"https://api.github.com/users/jareware/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-12-07T09:59:48Z","updated_at":"2015-05-21T20:07:26Z","closed_at":"2015-01-03T00:21:20Z","body":"If I use this fairly common pattern for object creation:\r\n```\r\nfunction createFooBar() {\r\n    return {\r\n        doThings() {}\r\n    };\r\n}\r\n```\r\n...is there any way for me to annotate other parts of my codebase as expecting the inferred return type of `createFooBar()`, along the lines of:\r\n```\r\nfunction baz(x : FooBar) {}\r\n```\r\nWould it be possible, for instance, to somehow alias the inferred return type into `FooBar`?\r\n\r\nI know I can declare `type FooBar = { doThings: () => void }` but I'd rather avoid the duplication, if possible! :)"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/104406074","html_url":"https://github.com/facebook/flow/issues/175#issuecomment-104406074","issue_url":"https://api.github.com/repos/facebook/flow/issues/175","id":104406074,"user":{"login":"mindeavor","id":17013,"avatar_url":"https://avatars.githubusercontent.com/u/17013?v=3","gravatar_id":"","url":"https://api.github.com/users/mindeavor","html_url":"https://github.com/mindeavor","followers_url":"https://api.github.com/users/mindeavor/followers","following_url":"https://api.github.com/users/mindeavor/following{/other_user}","gists_url":"https://api.github.com/users/mindeavor/gists{/gist_id}","starred_url":"https://api.github.com/users/mindeavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mindeavor/subscriptions","organizations_url":"https://api.github.com/users/mindeavor/orgs","repos_url":"https://api.github.com/users/mindeavor/repos","events_url":"https://api.github.com/users/mindeavor/events{/privacy}","received_events_url":"https://api.github.com/users/mindeavor/received_events","type":"User","site_admin":false},"created_at":"2015-05-21T20:07:26Z","updated_at":"2015-05-21T20:07:26Z","body":"Sure, I'm happy to create an issue. To be clear though, it's not related to the issue at hand. The line I labeled as a workaround is the problem; in order for flow to type check, I have use that workaround (run the code within my module with test data), or I have to annotate the return value of my controller as you suggested. Both require updating my code in two places. If I add unit tests, that becomes three places."}}