Title: Object.constructor isn't implemented specifically enough · Issue #4586 · microsoft/TypeScript · GitHub
Open Graph Title: Object.constructor isn't implemented specifically enough · Issue #4586 · microsoft/TypeScript
X Title: Object.constructor isn't implemented specifically enough · Issue #4586 · microsoft/TypeScript
Description: Consider: class Foo extends ([].constructor) { } [].constructor should be Array, which we aught to be able to extend. However, the checker complains on [].constructor that "Type 'Function' is not a constructor function type". Considering...
Open Graph Description: Consider: class Foo extends ([].constructor) { } [].constructor should be Array, which we aught to be able to extend. However, the checker complains on [].constructor that "Type 'Function' is not a...
X Description: Consider: class Foo extends ([].constructor) { } [].constructor should be Array, which we aught to be able to extend. However, the checker complains on [].constructor that "Type 'Function&...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/4586
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Object.constructor isn't implemented specifically enough","articleBody":"Consider:\n\n``` ts\nclass Foo extends ([].constructor) {\n}\n```\n\n`[].constructor` should be `Array`, which we aught to be able to extend. However, the checker complains on `[].constructor` that \"Type 'Function' is not a constructor function type\". Considering `.constructor` is _quite explicitly_ the constructor function for the object, I believe this is a lie perpetuated by our `lib.d.ts` files. I think we need to go add appropriate self-constructor-referencing `.constructor` fields to each builtin.\n\n_Additionally_ consider the following:\n\n``` ts\nclass Bar {\n}\n\nclass Foo extends ((new Bar()).constructor) {\n}\n```\n\nThe same thing but with a custom class rather than a builtin. We should know the correct type of `.constructor` here (the `Bar` class), but we don't - we just look at the members on `Object`.\n\nIn the first example, I believe it could be fixed with more precise lib files, but in the second case, I believe this is an instance of a field whose type should be known by the compiler, much like `.prototype` on the class itself is known.\n","author":{"url":"https://github.com/weswigham","@type":"Person","name":"weswigham"},"datePublished":"2015-09-01T01:46:22Z","url":"https://github.com/microsoft/TypeScript/issues/4586"}
| 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:4598f579-1656-959d-1ff5-baad7f8e5b10 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1E2:311640:F3B0C5:1366F79:6B010ED1 |
| html-safe-nonce | 9eb381856555fdef77d0006d15bfb885e8f746dde4edb6604e1a9a0fc77449f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUUyOjMxMTY0MDpGM0IwQzU6MTM2NkY3OTo2QjAxMEVEMSIsInZpc2l0b3JfaWQiOiI4OTU5MzQ4NzQyNDIzNjQ1OTA1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b168fd84d3e39ac5f7efa15afc0e6662ffae0410477a11004851402992828c22 |
| hovercard-subject-tag | issue:104166707 |
| 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/4586/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4437b3fe81e6e0ec03c8185bef12f10a75db2493a1e12db02c56c1690a187481/microsoft/TypeScript/issues/4586 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4437b3fe81e6e0ec03c8185bef12f10a75db2493a1e12db02c56c1690a187481/microsoft/TypeScript/issues/4586 |
| og:image:alt | Consider: class Foo extends ([].constructor) { } [].constructor should be Array, which we aught to be able to extend. However, the checker complains on [].constructor that "Type 'Function' is not a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | weswigham |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width