{"action":"created","issue":{"url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/351","labels_url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/351/labels{/name}","comments_url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/351/comments","events_url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/351/events","html_url":"https://github.com/TypeStrong/atom-typescript/issues/351","id":77340660,"number":351,"title":"Refactoring : extract variable","user":{"login":"geowarin","id":1045636,"avatar_url":"https://avatars.githubusercontent.com/u/1045636?v=3","gravatar_id":"","url":"https://api.github.com/users/geowarin","html_url":"https://github.com/geowarin","followers_url":"https://api.github.com/users/geowarin/followers","following_url":"https://api.github.com/users/geowarin/following{/other_user}","gists_url":"https://api.github.com/users/geowarin/gists{/gist_id}","starred_url":"https://api.github.com/users/geowarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geowarin/subscriptions","organizations_url":"https://api.github.com/users/geowarin/orgs","repos_url":"https://api.github.com/users/geowarin/repos","events_url":"https://api.github.com/users/geowarin/events{/privacy}","received_events_url":"https://api.github.com/users/geowarin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/TypeStrong/atom-typescript/labels/category:quick-fix","name":"category:quick-fix","color":"fbca04"},{"url":"https://api.github.com/repos/TypeStrong/atom-typescript/labels/up-for-grabs","name":"up-for-grabs","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-17T16:14:44Z","updated_at":"2015-05-18T00:59:15Z","closed_at":null,"body":"I think it would be nice to have a refactoring where you take a statement and put it into a variable.\r\n\r\nExample 1\r\n\r\n```typescript\r\nclass Example {\r\n   method():string {\r\n      return 'hello';\r\n   }\r\n}\r\n\r\nnew Example().hello()\r\n```\r\n\r\nextract variable on the `hello()` method =>\r\n\r\n```typescript\r\nclass Example {\r\n   method():string {\r\n      return 'hello';\r\n   }\r\n}\r\n\r\nvar hello:string = new Example().hello()\r\n```\r\n\r\nExample 2:\r\n\r\n```typescript\r\nclass Example {\r\n   method(num:number):string {\r\n      return 'hello ' + number;\r\n   }\r\n}\r\n\r\nnew Example().hello(42)\r\n```\r\n\r\nextract variable on the `42` parameter =>\r\n\r\n\r\n```typescript\r\nclass Example {\r\n   method(num:number):string {\r\n      return 'hello ' + number;\r\n   }\r\n}\r\n\r\nvar num:number = 42;\r\nnew Example().hello(num)\r\n```\r\n\r\nIn the first case, the name of the variable can be inferred from the method name and in the second, from the parameter name.\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/comments/102881039","html_url":"https://github.com/TypeStrong/atom-typescript/issues/351#issuecomment-102881039","issue_url":"https://api.github.com/repos/TypeStrong/atom-typescript/issues/351","id":102881039,"user":{"login":"basarat","id":874898,"avatar_url":"https://avatars.githubusercontent.com/u/874898?v=3","gravatar_id":"","url":"https://api.github.com/users/basarat","html_url":"https://github.com/basarat","followers_url":"https://api.github.com/users/basarat/followers","following_url":"https://api.github.com/users/basarat/following{/other_user}","gists_url":"https://api.github.com/users/basarat/gists{/gist_id}","starred_url":"https://api.github.com/users/basarat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basarat/subscriptions","organizations_url":"https://api.github.com/users/basarat/orgs","repos_url":"https://api.github.com/users/basarat/repos","events_url":"https://api.github.com/users/basarat/events{/privacy}","received_events_url":"https://api.github.com/users/basarat/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T00:59:15Z","updated_at":"2015-05-18T00:59:15Z","body":"> What do you think?\r\n\r\nReasonable request. Anything that make your life easier :rose: "}}