{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5138","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5138/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5138/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5138/events","html_url":"https://github.com/Microsoft/TypeScript/issues/5138","id":110080024,"number":5138,"title":"Type inference not working when assigning somewhere in the function chain","user":{"login":"cveld","id":6196260,"avatar_url":"https://avatars.githubusercontent.com/u/6196260?v=3","gravatar_id":"","url":"https://api.github.com/users/cveld","html_url":"https://github.com/cveld","followers_url":"https://api.github.com/users/cveld/followers","following_url":"https://api.github.com/users/cveld/following{/other_user}","gists_url":"https://api.github.com/users/cveld/gists{/gist_id}","starred_url":"https://api.github.com/users/cveld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cveld/subscriptions","organizations_url":"https://api.github.com/users/cveld/orgs","repos_url":"https://api.github.com/users/cveld/repos","events_url":"https://api.github.com/users/cveld/events{/privacy}","received_events_url":"https://api.github.com/users/cveld/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/By%20Design","name":"By Design","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T19:15:59Z","updated_at":"2015-10-06T19:49:50Z","closed_at":null,"body":"Using TypeScript 1.6 in Visual Studio 2015 RTM, the following code does not provide syntax highlighting:\r\n\r\n```javascript\r\nvar x;\r\n\r\nfunction init() {\r\n    x = {\r\n        color: \"blue\",\r\n        height: \"50\"\r\n    };\r\n}\r\n\r\ninit();\r\nx.???\r\n```\r\n\r\nIs this something on TypeScript's roadmap to solve?\r\nOr what is the best way to refactor? Ideally I would have intelligent support in Visual Studio that lifts the assignment towards the variable declaration, e.g.:\r\n\r\n```javascript\r\nvar x: { color; height };\r\nfunction init() {\r\n    x = {\r\n        color: \"blue\",\r\n        height: \"50\"\r\n    }\r\n}\r\n\r\ninit();\r\nx.color = ...\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/145977794","html_url":"https://github.com/Microsoft/TypeScript/issues/5138#issuecomment-145977794","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5138","id":145977794,"user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T19:49:50Z","updated_at":"2015-10-06T19:49:50Z","body":"We only infer from the initialization of a variable, not from other assignments. There is no plan to change that.\r\n\r\nI would write the code this way given what's declared:\r\n```ts\r\n\r\nfunction init() {\r\n    return {\r\n        color: \"blue\",\r\n        height: \"50\"\r\n    }\r\n}\r\n\r\nvar x = init();\r\nx.color = ...\r\n```"}}