{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1624","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1624/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1624/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1624/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1624","id":53855298,"number":1624,"title":"inferred parametric types are not checked by the compiler","user":{"login":"vujevits","id":2270661,"avatar_url":"https://avatars.githubusercontent.com/u/2270661?v=3","gravatar_id":"","url":"https://api.github.com/users/vujevits","html_url":"https://github.com/vujevits","followers_url":"https://api.github.com/users/vujevits/followers","following_url":"https://api.github.com/users/vujevits/following{/other_user}","gists_url":"https://api.github.com/users/vujevits/gists{/gist_id}","starred_url":"https://api.github.com/users/vujevits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vujevits/subscriptions","organizations_url":"https://api.github.com/users/vujevits/orgs","repos_url":"https://api.github.com/users/vujevits/repos","events_url":"https://api.github.com/users/vujevits/events{/privacy}","received_events_url":"https://api.github.com/users/vujevits/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/By+Design","name":"By Design","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-09T10:46:35Z","updated_at":"2015-01-09T16:45:23Z","closed_at":null,"body":"This compiles on the online playground, and tsc version 1.3.0 as well:\r\n\r\n```ts\r\nfunction foo():()=>Bar<string> {\r\n    return ()=>{ return new Bar<number>(); };\r\n}\r\n```\r\nupdate: a more simple example which should fail at compile time as well:\r\n```ts\r\nfunction foo():Bar<string> {\r\n\treturn  new Bar<number>();\r\n}\r\n```\r\n\r\n\r\nhttp://www.typescriptlang.org/Playground#src=class%20Bar%3CA%3E%0A{%0A}%0A%0Afunction%20foo%28%29%3A%28%29%3D%3EBar%3Cstring%3E%20{%0A%09return%20%28%29%3D%3E{%20return%20new%20Bar%3Cnumber%3E%28%29%3B%20}%3B%0A}%0A%0A"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/69361084","html_url":"https://github.com/Microsoft/TypeScript/issues/1624#issuecomment-69361084","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1624","id":69361084,"user":{"login":"ahejlsberg","id":4226954,"avatar_url":"https://avatars.githubusercontent.com/u/4226954?v=3","gravatar_id":"","url":"https://api.github.com/users/ahejlsberg","html_url":"https://github.com/ahejlsberg","followers_url":"https://api.github.com/users/ahejlsberg/followers","following_url":"https://api.github.com/users/ahejlsberg/following{/other_user}","gists_url":"https://api.github.com/users/ahejlsberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ahejlsberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahejlsberg/subscriptions","organizations_url":"https://api.github.com/users/ahejlsberg/orgs","repos_url":"https://api.github.com/users/ahejlsberg/repos","events_url":"https://api.github.com/users/ahejlsberg/events{/privacy}","received_events_url":"https://api.github.com/users/ahejlsberg/received_events","type":"User","site_admin":false},"created_at":"2015-01-09T16:45:23Z","updated_at":"2015-01-09T16:45:23Z","body":"The array example is different. The type of `arr` is inferred as `any[]` because there is no type annotation on the declaration and  no elements in the array literal from which to infer an element type. And since an `any[]` is assignment compatible with any array type, including `string[]`, there is no error.\r\n\r\nIf you compile with the `-noImplicitAny` flag (which disallows inferences of type `any`, requiring explicit type annotations in those cases) you will get an error on the declaration of `arr` because `any[]` was implicitly inferred.\r\n\r\nThe best way to write this particular example would be:\r\n```typescript\r\nfunction foo() {\r\n    var arr: string[] = [];\r\n    arr.push(5);  // Error here\r\n    return arr;\r\n}\r\n```\r\nWith or without `-noImplicitAny` this will give you an error."}}