Title: In JS, function declarations should allow subsequent prototype assignment · Issue #23007 · microsoft/TypeScript · GitHub
Open Graph Title: In JS, function declarations should allow subsequent prototype assignment · Issue #23007 · microsoft/TypeScript
X Title: In JS, function declarations should allow subsequent prototype assignment · Issue #23007 · microsoft/TypeScript
Description: // @allowJs: true // @checkJs: true // @Filename: a.js function C(p) { this.p = p } C.prototype = { m() { console.log(this.p) } } C.prototype.q = function(r) { return this.p === r } var c = new C(1) c.q(2) c.m() Expected behavior: Both q...
Open Graph Description: // @allowJs: true // @checkJs: true // @Filename: a.js function C(p) { this.p = p } C.prototype = { m() { console.log(this.p) } } C.prototype.q = function(r) { return this.p === r } var c = new C(1...
X Description: // @allowJs: true // @checkJs: true // @Filename: a.js function C(p) { this.p = p } C.prototype = { m() { console.log(this.p) } } C.prototype.q = function(r) { return this.p === r } var c = new C(1...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23007
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In JS, function declarations should allow subsequent prototype assignment","articleBody":"```js\r\n// @allowJs: true\r\n// @checkJs: true\r\n// @Filename: a.js\r\nfunction C(p) {\r\n this.p = p\r\n}\r\nC.prototype = {\r\n m() {\r\n console.log(this.p)\r\n }\r\n}\r\nC.prototype.q = function(r) {\r\n return this.p === r\r\n}\r\nvar c = new C(1)\r\nc.q(2)\r\nc.m()\r\n```\r\n\r\n**Expected behavior:**\r\nBoth `q` and `m` are methods on `c`.\r\n\r\n**Actual behavior:**\r\nOnly `q` is a method on `c`; `m` is not recognised.\r\n\r\nNote that if the declaration is `var C = function(p) { this.p = p }`, everything works. This only happens when `C` is a function declaration instead of a variable declaration with a function initialiser.","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2018-03-29T22:53:51Z","url":"https://github.com/microsoft/TypeScript/issues/23007"}
| 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:7eed4874-6936-9d67-5e03-f9ce6a7921d7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D5CC:1CCECA:88EE33:B717B4:6B01BC6B |
| html-safe-nonce | 3b80ccfd4927ebaa6adc73dae5c500ced285b0d2353c970cc2de847a4bf2684e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUNDOjFDQ0VDQTo4OEVFMzM6QjcxN0I0OjZCMDFCQzZCIiwidmlzaXRvcl9pZCI6IjYyMDk2MzI1MDI1Mjk3Njg1NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0a14f39db2f2a735a25d2a429a4cb5bae4b7ad8019119c17bd9852e659ff9c42 |
| hovercard-subject-tag | issue:309928488 |
| 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/23007/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6b2ba7358b01638d2422e2a8ef57561ecd5f4bcdb9eea8afb62d6a64d9e535a6/microsoft/TypeScript/issues/23007 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6b2ba7358b01638d2422e2a8ef57561ecd5f4bcdb9eea8afb62d6a64d9e535a6/microsoft/TypeScript/issues/23007 |
| og:image:alt | // @allowJs: true // @checkJs: true // @Filename: a.js function C(p) { this.p = p } C.prototype = { m() { console.log(this.p) } } C.prototype.q = function(r) { return this.p === r } var c = new C(1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sandersn |
| 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