{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14146","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14146/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14146/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14146/events","html_url":"https://github.com/Microsoft/TypeScript/issues/14146","id":208472455,"number":14146,"title":"TS2352:Type 'Object[keyof Object]' cannot be converted to type 'Date'","user":{"login":"Karasuni","id":15806406,"avatar_url":"https://avatars.githubusercontent.com/u/15806406?v=3","gravatar_id":"","url":"https://api.github.com/users/Karasuni","html_url":"https://github.com/Karasuni","followers_url":"https://api.github.com/users/Karasuni/followers","following_url":"https://api.github.com/users/Karasuni/following{/other_user}","gists_url":"https://api.github.com/users/Karasuni/gists{/gist_id}","starred_url":"https://api.github.com/users/Karasuni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karasuni/subscriptions","organizations_url":"https://api.github.com/users/Karasuni/orgs","repos_url":"https://api.github.com/users/Karasuni/repos","events_url":"https://api.github.com/users/Karasuni/events{/privacy}","received_events_url":"https://api.github.com/users/Karasuni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-17T15:22:54Z","updated_at":"2017-02-17T15:22:54Z","closed_at":null,"body":"<!-- BUGS: Please use this template. -->\r\n\r\n**TypeScript Version:**  2.1.6\r\n\r\nI've observed an issue with type casting in a function I've found and integrated from [here](https://gist.github.com/ghinda/8442a57f22099bdb2e34#gistcomment-1997213).\r\n\r\n**Code**\r\n```ts\r\n  createFormData<Object>(object: Object, form?: FormData, namespace?: string): FormData {\r\n    const formData = form || new FormData();\r\n    for (let property in object) {\r\n      if (!object.hasOwnProperty(property) || !object[property]) {\r\n        continue;\r\n      }\r\n      const formKey = namespace ? `${namespace}[${property}]` : property;\r\n      if (object[property] instanceof Date) {\r\n        formData.append(formKey, (<Date>object[property]).toISOString());\r\n//                                  ^\r\n      } else if (typeof object[property] === 'object' && !(object[property] instanceof File)) {\r\n        this.createFormData(object[property], formData, formKey);\r\n      } else {\r\n        formData.append(formKey, object[property]);\r\n      }\r\n    }\r\n    return formData;\r\n  }\r\n```\r\nOriginally the `instanceof Date` switch had no typecasting and would result in a `TS2339:Property 'toISOString' does not exist on type 'Object[keyof Object]'. Since the object is already checked as an instance of `Date` I've added the cast.\r\n\r\n**Expected behavior:**\r\nIt should not complain about typecasting.\r\n\r\n**Actual behavior:**\r\n`tsc` complains about not being able to cast an Object in an Object to a Date.\r\n\r\nCurrent workaround: `(<Date><any>object[property]).toISOString());`"}}
{"actor":{"display_login":"Karasuni"}}