Title: question: how can i create and return a generic function in TypeScript? · Issue #9949 · microsoft/TypeScript · GitHub
Open Graph Title: question: how can i create and return a generic function in TypeScript? · Issue #9949 · microsoft/TypeScript
X Title: question: how can i create and return a generic function in TypeScript? · Issue #9949 · microsoft/TypeScript
Description: function flip(fn: (one: a, two: b) => c): (one: b, two: a) => c { return function flipped(one: b, two: a): c { return fn(two, one); }; } function of2(one: a, two: b): [a, b] { return [one, two]; } const flipped = flip(of2)...
Open Graph Description: function flip(fn: (one: a, two: b) => c): (one: b, two: a) => c { return function flipped(one: b, two: a): c { return fn(two, one); }; } function of2(one: a, two: b): [a, b] { return...
X Description: function flip<a, b, c>(fn: (one: a, two: b) => c): (one: b, two: a) => c { return function flipped(one: b, two: a): c { return fn(two, one); }; } function of2<a, b>(one: a, two: b...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9949
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"question: how can i create and return a generic function in TypeScript?","articleBody":"``` typescript\nfunction flip\u003ca, b, c\u003e(fn: (one: a, two: b) =\u003e c): (one: b, two: a) =\u003e c {\n return function flipped(one: b, two: a): c {\n return fn(two, one);\n };\n}\nfunction of2\u003ca, b\u003e(one: a, two: b): [a, b] {\n return [one, two];\n}\nconst flipped = flip(of2); // expected: \u003ca, b\u003e(one: b, two: a) =\u003e [a, b], actual: (one: {}, two: {}) =\u003e [{}, {}]\n```\n","author":{"url":"https://github.com/zpdDG4gta8XKpMCd","@type":"Person","name":"zpdDG4gta8XKpMCd"},"datePublished":"2016-07-26T11:36:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":22},"url":"https://github.com/9949/TypeScript/issues/9949"}
| 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:b3ff157a-8521-4f5c-37b8-077f47d65f46 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BED6:89395:2F37CD:445F8F:6A620268 |
| html-safe-nonce | 71404134f1eed88614b32c54d743dc8ea09dbb263da06a9ff4d4a8be5963cc81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUQ2Ojg5Mzk1OjJGMzdDRDo0NDVGOEY6NkE2MjAyNjgiLCJ2aXNpdG9yX2lkIjoiNDI1OTYyMDkxOTUyOTU3MDkyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 41cfd1872a41ae4d5995ad48bee02b7f1b546a25c4acc4f174741b3ca9d63a8f |
| hovercard-subject-tag | issue:167586041 |
| 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/9949/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5093ddfd48d93ceaa2999a3df53e98032f5afbb71bbe8a53020d71b3fcc53e2d/microsoft/TypeScript/issues/9949 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5093ddfd48d93ceaa2999a3df53e98032f5afbb71bbe8a53020d71b3fcc53e2d/microsoft/TypeScript/issues/9949 |
| og:image:alt | function flip(fn: (one: a, two: b) => c): (one: b, two: a) => c { return function flipped(one: b, two: a): c { return fn(two, one); }; } function of2(one: a, two: b): [a, b] { return... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zpdDG4gta8XKpMCd |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92eeba52656842b5eb8a3f62fd6465e80107329999099c7144d43d7476b38ad0 |
| 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 | 14dbe1e269fc16133b0b2bbc058e3a259cd85df4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width