Title: Why do TypeScript function and index signatures require naming variables? · Issue #13152 · microsoft/TypeScript · GitHub
Open Graph Title: Why do TypeScript function and index signatures require naming variables? · Issue #13152 · microsoft/TypeScript
X Title: Why do TypeScript function and index signatures require naming variables? · Issue #13152 · microsoft/TypeScript
Description: TypeScript Version: all versions up to 2.1.4 This is something that's confused me for a long time about TypeScript. Why is it required to name the parameter x in the type expression (x: A) => B? I know it's possible to use typeof with an...
Open Graph Description: TypeScript Version: all versions up to 2.1.4 This is something that's confused me for a long time about TypeScript. Why is it required to name the parameter x in the type expression (x: A) => B? I ...
X Description: TypeScript Version: all versions up to 2.1.4 This is something that's confused me for a long time about TypeScript. Why is it required to name the parameter x in the type expression (x: A) =>...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13152
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why do TypeScript function and index signatures require naming variables?","articleBody":"**TypeScript Version:** all versions up to 2.1.4\r\n\r\nThis is something that's confused me for a long time about TypeScript. Why is it required to name the parameter `x` in the type expression `(x: A) => B`? I know it's possible to use `typeof` with an expression involving the term, but this is a fairly niche use case, so that most of the time the variable goes unused. I understand that for documentation purposes it can be nice to name the function variables in a type signature. I'm fine with that, but far more important to me is knowing the _type_ of the argument. When first learning TypeScript I was very surprised to learn that, while `(A) => B` is a valid type expression, it takes the `A` to be the name of the _argument_, not the type, and assumes you meant the type to be `any`! Turning on `noImplicitAny` eliminates the bugs that can result from that confusion, but it also renders the shorthand `(A) => B` unusable.\r\n\r\nIs it too late to reconsider this design decision? Since `A => B` (without the parens around `A`) is currently syntactically invalid as a type, it should be completely backwards compatible to support it as a shorthand for `(__nameless_variable__: A) => B`.","author":{"url":"https://github.com/pelotom","@type":"Person","name":"pelotom"},"datePublished":"2016-12-23T23:24:01Z","url":"https://github.com/microsoft/TypeScript/issues/13152"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b4010cb7-85af-d783-4036-7e34adf1e907 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A982:842EC:988D2D:CD39EC:6B00EA32 |
| html-safe-nonce | ce03c45426a9db00877f27f0de833bb5e5d88c5796f0c4d8cb769b8b073c3b41 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTgyOjg0MkVDOjk4OEQyRDpDRDM5RUM6NkIwMEVBMzIiLCJ2aXNpdG9yX2lkIjoiMTUxNTc3NTU3MzUyMjE4MDY1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 966ae81087029b2a707903b012afb99038158a1eb50db8082bb7a5657c547c62 |
| hovercard-subject-tag | issue:197436741 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/13152/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7932e9f16f86e8327e7ae64240e14ce66e5031d92d59d40ec248929f9a12e33f/microsoft/TypeScript/issues/13152 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7932e9f16f86e8327e7ae64240e14ce66e5031d92d59d40ec248929f9a12e33f/microsoft/TypeScript/issues/13152 |
| og:image:alt | TypeScript Version: all versions up to 2.1.4 This is something that's confused me for a long time about TypeScript. Why is it required to name the parameter x in the type expression (x: A) => B? I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pelotom |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width