Title: Typed ...rest parameters with generics · Issue #1024 · microsoft/TypeScript · GitHub
Open Graph Title: Typed ...rest parameters with generics · Issue #1024 · microsoft/TypeScript
X Title: Typed ...rest parameters with generics · Issue #1024 · microsoft/TypeScript
Description: Is it possible to add type info to the rest parameters in a way that each individual parameter can have a different type? This works, but with this there can be any number parameters, and all have to have the same type: function myFuncti...
Open Graph Description: Is it possible to add type info to the rest parameters in a way that each individual parameter can have a different type? This works, but with this there can be any number parameters, and all have ...
X Description: Is it possible to add type info to the rest parameters in a way that each individual parameter can have a different type? This works, but with this there can be any number parameters, and all have ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/1024
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typed ...rest parameters with generics","articleBody":"Is it possible to add type info to the rest parameters in a way that each individual parameter can have a different type?\n\nThis works, but with this there can be any number parameters, and all have to have the same type:\n\n```\nfunction myFunction\u003cT\u003e(...args:T[]) {\n}\nmyFunction\u003cnumber\u003e(1, 3);\n```\n\nIt would be really useful if I could force the exact number of arguments and the types for each one, but all this within generics, so something like this (but this is obviously syntactically wrong):\n\n```\nfunction myFunction\u003cT\u003e(...args:T) {\n}\n\ninterface MyParams {\n [0]:string;\n [1]:number;\n}\n\nmyFunction\u003cMyParams\u003e(\"a\", 1)\n```\n\nAn example use case is writing an observer class that the user could specify the arguments of the listener functions for:\n\n```\nclass Observer\u003cT\u003e {\n addListener(...args:T) {\n }\n}\n```\n\nIf this is not supported, what do you recommend using instead? I can use any[] of course, or living with the constraint of having a fixed number of fixed typed parameters.\n","author":{"url":"https://github.com/andrewvarga","@type":"Person","name":"andrewvarga"},"datePublished":"2014-11-01T14:00:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/1024/TypeScript/issues/1024"}
| 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:888d5a5d-adb1-2a50-54e9-c42ab42e6067 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA1A:A1309:78FB29:A20C9A:6A618448 |
| html-safe-nonce | cd8d72d21e67ff988c56df84e2931e7f0c7a4b5beb6525f095833db1856bddba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTFBOkExMzA5Ojc4RkIyOTpBMjBDOUE6NkE2MTg0NDgiLCJ2aXNpdG9yX2lkIjoiMTEyMDE0MDM0MDMwMzU5NDU2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c7579cf6b0fd182ed32f261518ce49578414eb0d325eb2abfa18dc7c22196c96 |
| hovercard-subject-tag | issue:47506552 |
| 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/1024/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f2a97e37f8c5f391df7fef59040ad1cb1e7b5ec51af7e6d43cdcdcdfe3b19b68/microsoft/TypeScript/issues/1024 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f2a97e37f8c5f391df7fef59040ad1cb1e7b5ec51af7e6d43cdcdcdfe3b19b68/microsoft/TypeScript/issues/1024 |
| og:image:alt | Is it possible to add type info to the rest parameters in a way that each individual parameter can have a different type? This works, but with this there can be any number parameters, and all have ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andrewvarga |
| hostname | github.com |
| expected-hostname | github.com |
| None | c28c2f6607f2aacbd934868d997038895c9780d08babfe918550d73773326f4c |
| 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 | cd05235d52ffb3318513d883a56c87a121015c8b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width