Title: Problem with declaration file generated from generic extended function · Issue #17840 · microsoft/TypeScript · GitHub
Open Graph Title: Problem with declaration file generated from generic extended function · Issue #17840 · microsoft/TypeScript
X Title: Problem with declaration file generated from generic extended function · Issue #17840 · microsoft/TypeScript
Description: I have code like so: export class A
Open Graph Description: I have code like so: export class A
X Description: I have code like so: export class A<T> { // } export type Constructor<T> = new (...args: any[]) => T; export function foo<T extends Constructor<{}>>(Base: T): T & Con...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17840
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problem with declaration file generated from generic extended function","articleBody":"I have code like so:\r\n\r\n```\r\nexport class A\u003cT> {\r\n\t//\r\n}\r\nexport type Constructor\u003cT> = new (...args: any[]) => T;\r\n\r\nexport function foo\u003cT extends Constructor\u003c{}>>(Base: T): T & Constructor\u003c{}> {\r\n\treturn class extends Base {};\r\n}\r\n\r\nexport class B\u003cT> extends foo\u003cConstructor\u003cA\u003cT>>>(A) {}\r\n\r\n```\r\n\r\n(This is an over simplified version of real code just to show the problem)\r\n\r\nThe generated `.d.ts` file does not compile\r\n\r\n```\r\nexport declare class A\u003cT> {}\r\n\r\nexport declare type Constructor\u003cT> = new (...args: any[]) => T;\r\n\r\nexport declare function foo\u003cT extends Constructor\u003c{}>>(Base: T): T & Constructor\u003c{}>;\r\n\r\ndeclare const B_base: Constructor\u003cA\u003cT>> & Constructor\u003c{}>;\r\n\r\nexport declare class B\u003cT> extends B_base {}\r\n```\r\nAs you can see the extending function is compiled to a const `B_Base` and since consts can not be generic this line throws an error when using the definition file.","author":{"url":"https://github.com/nayish","@type":"Person","name":"nayish"},"datePublished":"2017-08-16T19:35:48Z","url":"https://github.com/microsoft/TypeScript/issues/17840"}
| 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:b099c058-468b-1036-c198-916e4ee764c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84D0:11486D:AFF493:E4FFB0:6B00E9EB |
| html-safe-nonce | a2ff2dfc2487ff640e35980864bb895733951b766fca6b4f808354c9e6e5a112 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEQwOjExNDg2RDpBRkY0OTM6RTRGRkIwOjZCMDBFOUVCIiwidmlzaXRvcl9pZCI6IjE1MzA2Nzc4NjAyMDM4MTc0NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 288333ebfa8e365ca587eab914837656842de18d12e62715693eba394222662c |
| hovercard-subject-tag | issue:250735886 |
| 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/17840/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e17d867210a732c04777c74226db76bae2cc21c84930783785247f75309e7b45/microsoft/TypeScript/issues/17840 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e17d867210a732c04777c74226db76bae2cc21c84930783785247f75309e7b45/microsoft/TypeScript/issues/17840 |
| og:image:alt | I have code like so: export class A |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nayish |
| 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