Title: T.constructor should be of type T · Issue #3841 · microsoft/TypeScript · GitHub
Open Graph Title: T.constructor should be of type T · Issue #3841 · microsoft/TypeScript
X Title: T.constructor should be of type T · Issue #3841 · microsoft/TypeScript
Description: Given class Example { } The current type of Example.constructor is Function, but I feel that it should be typeof Example instead. The use case for this is as follows: I'd like to reference the current value of an overridden static proper...
Open Graph Description: Given class Example { } The current type of Example.constructor is Function, but I feel that it should be typeof Example instead. The use case for this is as follows: I'd like to reference the curr...
X Description: Given class Example { } The current type of Example.constructor is Function, but I feel that it should be typeof Example instead. The use case for this is as follows: I'd like to reference the ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3841
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"T.constructor should be of type T","articleBody":"Given\n\n``` typescript\nclass Example {\n}\n```\n\nThe current type of `Example.constructor` is `Function`, but I feel that it should be `typeof Example` instead. The use case for this is as follows:\n\nI'd like to reference the current value of an overridden static property on the current class.\n\nIn TypeScript v1.5-beta, doing this requires:\n\n``` typescript\nclass Example {\n static someProperty = \"Hello, world!\";\n\n constructor() {\n // Output overloaded value of someProperty, if it is overloaded.\n console.log(\n (\u003ctypeof Example>this.constructor).someProperty\n );\n }\n}\n\nclass SubExample {\n static someProperty = \"Overloaded! Hello world!\";\n\n someMethod() {\n console.log(\n (\u003ctypeof SubExample>this.constructor).someProperty\n );\n }\n}\n```\n\nAfter this proposal, the above block could be shortened to:\n\n``` typescript\nclass Example {\n static someProperty = \"Hello, world!\";\n\n constructor() {\n // Output overloaded value of someProperty, if it is overloaded.\n console.log(\n this.constructor.someProperty\n );\n }\n}\n\nclass SubExample {\n static someProperty = \"Overloaded! Hello world!\";\n\n someMethod() {\n console.log(\n this.constructor.someProperty\n );\n }\n}\n```\n\nThis removes a cast to the current class.\n","author":{"url":"https://github.com/LPGhatguy","@type":"Person","name":"LPGhatguy"},"datePublished":"2015-07-13T17:43:48Z","url":"https://github.com/microsoft/TypeScript/issues/3841"}
| 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:a72c792b-9742-4b54-e410-7e35900ccf0b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF30:2D2F2F:E58558:128B8F7:6B00F95F |
| html-safe-nonce | 7c68a8b310e09c9723052964f249fab28e813649f955b0913ed7b05f099f02c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjMwOjJEMkYyRjpFNTg1NTg6MTI4QjhGNzo2QjAwRjk1RiIsInZpc2l0b3JfaWQiOiI4Mjc4NzAwMTcwOTQyNjc1Mjk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cc417da39377244c72b462e7d450842cbeb67ed14105fa199b57cdcaa4e2617b |
| hovercard-subject-tag | issue:94773334 |
| 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/3841/issue_layout |
| twitter:image | https://opengraph.githubassets.com/775456f9dae3f7af6ac27bc88e46b15186bedb16340643caf089321ce746365b/microsoft/TypeScript/issues/3841 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/775456f9dae3f7af6ac27bc88e46b15186bedb16340643caf089321ce746365b/microsoft/TypeScript/issues/3841 |
| og:image:alt | Given class Example { } The current type of Example.constructor is Function, but I feel that it should be typeof Example instead. The use case for this is as follows: I'd like to reference the curr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LPGhatguy |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width