Title: A readonly class property that overrides a non-readonly property can still be reassigned in the base class (and vice-versa) · Issue #8496 · microsoft/TypeScript · GitHub
Open Graph Title: A readonly class property that overrides a non-readonly property can still be reassigned in the base class (and vice-versa) · Issue #8496 · microsoft/TypeScript
X Title: A readonly class property that overrides a non-readonly property can still be reassigned in the base class (and vice-versa) · Issue #8496 · microsoft/TypeScript
Description: TypeScript Version: 1.9.0-dev.20160506 Code class Base { prop: number; baseMethod() { this.prop = 4321; } } class Derived extends Base { readonly prop: number = 1234; // this could also be an accidental name collision derivedMethod() { t...
Open Graph Description: TypeScript Version: 1.9.0-dev.20160506 Code class Base { prop: number; baseMethod() { this.prop = 4321; } } class Derived extends Base { readonly prop: number = 1234; // this could also be an accid...
X Description: TypeScript Version: 1.9.0-dev.20160506 Code class Base { prop: number; baseMethod() { this.prop = 4321; } } class Derived extends Base { readonly prop: number = 1234; // this could also be an accid...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/8496
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A readonly class property that overrides a non-readonly property can still be reassigned in the base class (and vice-versa)","articleBody":"**TypeScript Version:** \n`1.9.0-dev.20160506`\n\n**Code**\n\n``` ts\nclass Base {\n prop: number;\n\n baseMethod() {\n this.prop = 4321;\n }\n}\n\nclass Derived extends Base {\n readonly prop: number = 1234; // this could also be an accidental name collision\n\n derivedMethod() {\n this.baseMethod();\n }\n}\n\nlet x = new Derived();\nconsole.log(x.prop); // prints 1234\nx.derivedMethod();\nconsole.log(x.prop); // prints 4321\n```\n\n**Expected behavior:**\nTrying to re-declare `prop` as `readonly` in `Derived` should error:\n\n```\nA writable property cannot be overriden by a readonly property\n```\n\n**Actual behavior:** \nNo error, `prop` can be reassigned in the base class.\n","author":{"url":"https://github.com/malibuzios","@type":"Person","name":"malibuzios"},"datePublished":"2016-05-06T09:25:59Z","url":"https://github.com/microsoft/TypeScript/issues/8496"}
| 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:f2d615ff-1180-0b0b-a368-2f0fc164e4a7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBC0:F14C:9A906:D58D4:6AFBC872 |
| html-safe-nonce | fef593bce60ad0cf323ce85d21dc226287dc7408e0b225be82daa98b0d761336 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkMwOkYxNEM6OUE5MDY6RDU4RDQ6NkFGQkM4NzIiLCJ2aXNpdG9yX2lkIjoiNDk5ODM2MjQxNTUwNzQyNTM5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1dc7cb71a5cb5a2d074a656c1dc709f1e6c76174547839c23961c7ba92635d51 |
| hovercard-subject-tag | issue:153413229 |
| 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/8496/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b4a2f0703dae074400a1bd2babda79240161294c19a64d94f0ece47487e25e91/microsoft/TypeScript/issues/8496 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b4a2f0703dae074400a1bd2babda79240161294c19a64d94f0ece47487e25e91/microsoft/TypeScript/issues/8496 |
| og:image:alt | TypeScript Version: 1.9.0-dev.20160506 Code class Base { prop: number; baseMethod() { this.prop = 4321; } } class Derived extends Base { readonly prop: number = 1234; // this could also be an accid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | malibuzios |
| hostname | github.com |
| expected-hostname | github.com |
| None | d440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b |
| 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 | 2c43021aed8695990c86c0eaaedc600bfeffec36 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width