{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3081","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3081/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3081/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3081/events","html_url":"https://github.com/Microsoft/TypeScript/issues/3081","id":74251122,"number":3081,"title":"Make type annotations in function type literals mandatory","user":{"login":"DanielRosenwasser","id":972891,"avatar_url":"https://avatars.githubusercontent.com/u/972891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielRosenwasser","html_url":"https://github.com/DanielRosenwasser","followers_url":"https://api.github.com/users/DanielRosenwasser/followers","following_url":"https://api.github.com/users/DanielRosenwasser/following{/other_user}","gists_url":"https://api.github.com/users/DanielRosenwasser/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielRosenwasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielRosenwasser/subscriptions","organizations_url":"https://api.github.com/users/DanielRosenwasser/orgs","repos_url":"https://api.github.com/users/DanielRosenwasser/repos","events_url":"https://api.github.com/users/DanielRosenwasser/events{/privacy}","received_events_url":"https://api.github.com/users/DanielRosenwasser/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Breaking%20Change","name":"Breaking Change","color":"eb6420"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Declined","name":"Declined","color":"556677"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-05-08T06:28:11Z","updated_at":"2015-10-09T16:57:34Z","closed_at":"2015-06-17T18:35:30Z","body":"Too many times do we have new users using function type literals without type annotations on their parameters - recently, #3080. Currently the following:\r\n\r\n```TypeScript\r\nvar x: (number, string) => void;\r\n```\r\n\r\nis implicitly typed like:\r\n\r\n```TypeScript\r\nvar x: (number: any, string: any) => void;\r\n```\r\n\r\neven though a user probably meant to type `x` like in the following way:\r\n\r\n```TypeScript\r\nvar x: (a: number, b: string) => void;\r\n```\r\n\r\nIt is actually extremely strange that parameter names, which function purely for documentation, are *mandatory* while their type annotations are *optional*.\r\n\r\nWhile `--noImplicitAny` catches this, new users often don't know about that flag to begin with.\r\n\r\nI don't see a good use case for a user who is wiling to type out an arrow type, but wants their parameters to implicitly be typed as `any`. While this is a breaking change, I'm sure most of the breaks would be with code like in the given example."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/146930581","html_url":"https://github.com/Microsoft/TypeScript/issues/3081#issuecomment-146930581","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3081","id":146930581,"user":{"login":"alexeagle","id":47395,"avatar_url":"https://avatars.githubusercontent.com/u/47395?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeagle","html_url":"https://github.com/alexeagle","followers_url":"https://api.github.com/users/alexeagle/followers","following_url":"https://api.github.com/users/alexeagle/following{/other_user}","gists_url":"https://api.github.com/users/alexeagle/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeagle/subscriptions","organizations_url":"https://api.github.com/users/alexeagle/orgs","repos_url":"https://api.github.com/users/alexeagle/repos","events_url":"https://api.github.com/users/alexeagle/events{/privacy}","received_events_url":"https://api.github.com/users/alexeagle/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T16:57:34Z","updated_at":"2015-10-09T16:57:34Z","body":"TSLint does allow to fix the problem, but it has the downside of disallowing code which is probably okay. I would rather have a static analysis check that the names of the parameters are not also valid types in the scope. So this would be okay shorthand:\r\n\r\n`function funcFactory(): (_) => void { ... } `\r\n\r\nbut this would be an error:\r\n\r\n`function funcFactory(): (number) => void { ... } `\r\n\r\nand also an error:\r\n\r\n`function funcFactory<T>(): (T) => void { ... } `"}}