Title: Smart structural generic type inference support · Issue #23733 · microsoft/TypeScript · GitHub
Open Graph Title: Smart structural generic type inference support · Issue #23733 · microsoft/TypeScript
X Title: Smart structural generic type inference support · Issue #23733 · microsoft/TypeScript
Description: TypeScript Version: 2.8.1 Problem: when there are too many generic parameters (e.g. nested generic interfaces), it gets hard to remember the order of those parameters. Some smart structural generic type inference needed. Code type Comple...
Open Graph Description: TypeScript Version: 2.8.1 Problem: when there are too many generic parameters (e.g. nested generic interfaces), it gets hard to remember the order of those parameters. Some smart structural generic...
X Description: TypeScript Version: 2.8.1 Problem: when there are too many generic parameters (e.g. nested generic interfaces), it gets hard to remember the order of those parameters. Some smart structural generic...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23733
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Smart structural generic type inference support","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.8.1\r\n\r\nProblem: when there are too many generic parameters (e.g. nested generic interfaces), it gets hard to remember the order of those parameters. Some smart structural generic type inference needed.\r\n\r\n**Code**\r\n\r\n```ts\r\ntype ComplexGeneric1\u003cTArg1, TArg2>={\r\n arg1:TArg1,\r\n arg2:TArg2,\r\n}\r\ntype ComplexGeneric2\u003cTArg1, TArg2>={\r\n arg1:TArg1,\r\n arg2:TArg2,\r\n}\r\n\r\ninterface IMyInterface\u003cTArg11=number,TArg12=number, TArg21=number, TArg22=number>\r\n{\r\n myFunc(p1:ComplexGeneric1\u003cTArg11, TArg12>, p2:ComplexGeneric2\u003cTArg21, TArg22>);\r\n}\r\n\r\nvar actualImplementation:IMyInterface\u003cnumber,string,number, string>={\r\n myFunc(p1,p2)\r\n {\r\n //\r\n }\r\n}\r\n\r\n```\r\nThere should be a way to declare IMyInterface generic to be able to create implementation the following way:\r\n```ts\r\n\r\nvar desiredImplementation:IMyInterface\u003c{ \r\n p1:{arg1:number, arg2:string},\r\n p2:{arg1:number, arg2:string}\r\n }>=\r\n{\r\n myFunc(p1,p2)\r\n {\r\n //p1.arg1 = 123\r\n //p1.arg2 = \"hello world\"\r\n }\r\n}\r\n```\r\n\r\nIs there a way to define IMyInterface to make it happen? Am I the only one who would like to have it?\r\n\r\nI would expect something like this to work, but it doesn't:\r\n```ts\r\ninterface IMyInterface\u003cTStructure extends ({p1: {arg1:TArg11, arg2:TArg12},p2:{arg1:TArg21, arg2:TArg22}}), TArg11=number,TArg12=number, TArg21=number, TArg22=number>\r\n{\r\n myFunc(p1:ComplexGeneric1\u003cTArg11, TArg12>, p2:ComplexGeneric2\u003cTArg21, TArg22>);\r\n}\r\n\r\n```\r\n","author":{"url":"https://github.com/pmunin","@type":"Person","name":"pmunin"},"datePublished":"2018-04-27T03:00:44Z","url":"https://github.com/microsoft/TypeScript/issues/23733"}
| 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:38186257-5e7c-3ef5-2cf9-c340b86e88fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF84:38C5CF:389C95E:47D0215:6B01D50E |
| html-safe-nonce | 6ccc52d2a2c64fb294cc321cc36751a41b1b0921335cb67593f24aaeec47e346 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjg0OjM4QzVDRjozODlDOTVFOjQ3RDAyMTU6NkIwMUQ1MEUiLCJ2aXNpdG9yX2lkIjoiOTEwNDAxOTU5MzUzMjc1MDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fe37a60bd982afac9b582f95205e45735f2ee23635a67cd3cd78c0f3a6e1d081 |
| hovercard-subject-tag | issue:318261936 |
| 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/23733/issue_layout |
| twitter:image | https://opengraph.githubassets.com/33cc0f0379c4062a6860b31ca7bc405d3b29b3daad5336c66aa6a6aefdd954f2/microsoft/TypeScript/issues/23733 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/33cc0f0379c4062a6860b31ca7bc405d3b29b3daad5336c66aa6a6aefdd954f2/microsoft/TypeScript/issues/23733 |
| og:image:alt | TypeScript Version: 2.8.1 Problem: when there are too many generic parameters (e.g. nested generic interfaces), it gets hard to remember the order of those parameters. Some smart structural generic... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pmunin |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width