Title: Constraints should be inference sites for other type parameters · Issue #7234 · microsoft/TypeScript · GitHub
Open Graph Title: Constraints should be inference sites for other type parameters · Issue #7234 · microsoft/TypeScript
X Title: Constraints should be inference sites for other type parameters · Issue #7234 · microsoft/TypeScript
Description: TypeScript Version: 1.8.0 Code interface Class
Open Graph Description: TypeScript Version: 1.8.0 Code interface Class
X Description: TypeScript Version: 1.8.0 Code interface Class<T> { new(): T; } declare function create1<T>(ctor: Class<T>): T; declare function create2<T, C extends Class<T>>(ctor: C...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7234
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constraints should be inference sites for other type parameters","articleBody":"\u003c!--\nThank you for contributing to TypeScript! Please review this checklist\n before submitting your issue.\n[ ] Many common issues and suggestions are addressed in the FAQ\n https://github.com/Microsoft/TypeScript/wiki/FAQ\n[ ] Search for duplicates before logging new issues\n https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue\n[ ] Questions are best asked and answered at Stack Overflow\n http://stackoverflow.com/questions/tagged/typescript\n\nFor bug reports, please include the information below.\n__________________________________________________________ -->\n\n**TypeScript Version:** \n\n1.8.0\n\n**Code**\n\n``` ts\ninterface Class\u003cT> {\n new(): T;\n}\ndeclare function create1\u003cT>(ctor: Class\u003cT>): T;\ndeclare function create2\u003cT, C extends Class\u003cT>>(ctor: C): T;\n\nclass A {}\nlet a1 = create1(A); // a: A --> OK\nlet a2 = create2(A); // a: {} --> Should be A\n```\n\n**Context**\n\nThe example above is simplified to illustrate the difference between `create1` and `create2`. I need both type parameters for the use case I have in mind (React) because it returns a type which is parameterized by both `T` and `C`:\n\n``` ts\ndeclare function createElement\u003cT, C extends Class\u003cT>>(type: C): Element\u003cT, C>;\nvar e = createElement(A); // e: Element\u003c{}, typeof A> --> Should be Element\u003cA, typeof A>\n\ndeclare function render\u003cT>(e: Element\u003cT, any>): T;\nvar a = render(e); // a: {} --> Should be A\n```\n\nAgain, this is simplified, but the motivation is to improve the return type inference of `ReactDOM.render`.\n","author":{"url":"https://github.com/vsiao","@type":"Person","name":"vsiao"},"datePublished":"2016-02-25T05:57:09Z","url":"https://github.com/microsoft/TypeScript/issues/7234"}
| 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:124c60d5-b21a-350f-565d-260f2a880d44 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4D8:172B92:4F0616:6BD4D2:6B00CEED |
| html-safe-nonce | a62a309776640dcb7d49da1ab906f34a167a8ff1a831d5a96bf05d431b3a2e81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEQ4OjE3MkI5Mjo0RjA2MTY6NkJENEQyOjZCMDBDRUVEIiwidmlzaXRvcl9pZCI6IjgxNDIwNDUxMDkxMzE3MjY1NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c16cb5d993f0349b91c5e20469ad083d5f23e1068d188f9ade2317b0ecc8ea3e |
| hovercard-subject-tag | issue:136289924 |
| 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/7234/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d862a1ff9b8ec22ca87aff3a4489f701258886ff95e48227417b94c39d189805/microsoft/TypeScript/issues/7234 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d862a1ff9b8ec22ca87aff3a4489f701258886ff95e48227417b94c39d189805/microsoft/TypeScript/issues/7234 |
| og:image:alt | TypeScript Version: 1.8.0 Code interface Class |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vsiao |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| 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 | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width