{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3666","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3666/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3666/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3666/events","html_url":"https://github.com/Microsoft/TypeScript/issues/3666","id":91669978,"number":3666,"title":"Error in a case without type annotation.","user":{"login":"laco0416","id":1529180,"avatar_url":"https://avatars.githubusercontent.com/u/1529180?v=3","gravatar_id":"","url":"https://api.github.com/users/laco0416","html_url":"https://github.com/laco0416","followers_url":"https://api.github.com/users/laco0416/followers","following_url":"https://api.github.com/users/laco0416/following{/other_user}","gists_url":"https://api.github.com/users/laco0416/gists{/gist_id}","starred_url":"https://api.github.com/users/laco0416/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laco0416/subscriptions","organizations_url":"https://api.github.com/users/laco0416/orgs","repos_url":"https://api.github.com/users/laco0416/repos","events_url":"https://api.github.com/users/laco0416/events{/privacy}","received_events_url":"https://api.github.com/users/laco0416/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-29T02:09:57Z","updated_at":"2015-06-29T04:51:28Z","closed_at":null,"body":"[Playground](http://www.typescriptlang.org/Playground#src=interface%20PolymerElement%20%7B%0D%0A%20%20properties%3F%3A%20%7B%20%5BpropName%3A%20string%5D%3A%20StringConstructor%7CPolymerElementProperty%20%7D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20PolymerElementProperty%20%7B%0D%0A%20%20type%3A%20StringConstructor%3B%0D%0A%7D%0D%0A%0D%0A%2F%2F%20Why%20is%20this%20incorrectly%20implements%3F%0D%0Aclass%20WithoutTypeAnnotation%20implements%20PolymerElement%20%7B%0D%0A%09properties%20%3D%20%7B%0D%0A%09%09prop1%3A%20String%2C%0D%0A%09%09prop2%3A%20%7B%0D%0A%09%09%09type%3A%20String%0D%0A%09%09%7D%0D%0A%09%7D%3B%0D%0A%7D%0D%0A%0D%0Aclass%20WithTypeAnnotation%20implements%20PolymerElement%20%7B%0D%0A%09properties%3A%7B%20%5BpropName%3A%20string%5D%3A%20StringConstructor%7CPolymerElementProperty%20%7D%20%3D%20%7B%0D%0A%09%09prop1%3A%20String%2C%0D%0A%09%09prop2%3A%20%7B%0D%0A%09%09%09type%3A%20String%0D%0A%09%09%7D%0D%0A%09%7D%3B%0D%0A%7D%0D%0A%0D%0A)\r\n\r\n```typescript\r\ninterface PolymerElement {\r\n  properties?: { [propName: string]: StringConstructor|PolymerElementProperty };\r\n}\r\n\r\ninterface PolymerElementProperty {\r\n  type: StringConstructor;\r\n}\r\n\r\n// Why is this incorrectly implements?\r\nclass WithoutTypeAnnotation implements PolymerElement {\r\n\tproperties = {\r\n\t\tprop1: String,\r\n\t\tprop2: {\r\n\t\t\ttype: String\r\n\t\t}\r\n\t};\r\n}\r\n\r\nclass WithTypeAnnotation implements PolymerElement {\r\n\tproperties:{ [propName: string]: StringConstructor|PolymerElementProperty } = {\r\n\t\tprop1: String,\r\n\t\tprop2: {\r\n\t\t\ttype: String\r\n\t\t}\r\n\t};\r\n}\r\n```\r\n\r\nBoth `properties` are same object, but tsc occurs error in  a case without type annotation. Why?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/116433264","html_url":"https://github.com/Microsoft/TypeScript/issues/3666#issuecomment-116433264","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3666","id":116433264,"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-06-29T04:51:28Z","updated_at":"2015-06-29T04:51:28Z","body":"Necessary background: http://stackoverflow.com/questions/22077023/why-cant-i-indirectly-return-an-object-literal-to-satisfy-an-index-signature-re\r\n\r\nThe root problem here is that we don't contextually type class property initializers with the type the property \"should\" have from an `implements` or `extends` clause. Without a contextual type on the object literal, the property is inferred to not have an index signature.\r\n\r\nLogged #3667 as this has been a long-standing pain point."}}