[feature] class properties that are "readonly in public, writable in private" or other permutations
<!-- π¨ STOP π¨ π¦π§π’π£ π¨ πΊπ»πΆπ· π¨ Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ, especially the "Common Feature Requests" section: https://github.com/Microsoft/TypeScript/wiki/FAQ --> ## Search Terms [typescript readonly on the outside writable on the inside](https://www.google.com/search?q=typescript%20readonly%20on%20the%20outside%20writable%20on%20the%20inside&cad=h) - https://stackoverflow.com/questions/46634876/how-can-i-change-a-readonly-property-in-typescript ## Suggestion Some sort of syntax to describe `readonly on the outside, writeable on the inside` for a given property, so we can avoid making a getter just for this purpose (or using any of the convoluted options linked in that StackOverflow post). ## Use Cases To make this pattern easier to express. ## Examples instead of having to write ```ts class Foo { private _foo = 123 get foo() { return this._foo } changeIt() { this._foo = 456 } } const f = new Foo f.foo = 345 // ERROR ``` we would be able to write something shorter like ```ts class Foo { publicread foo = 123 changeIt() { this.foo = 456 } } const f = new Foo f.foo = 345 // ERROR ``` ## Checklist My suggestion meets these guidelines: * [x] This wouldn't be a breaking change in existing Typ
Posted by trusktr on Mar 20, 2020, 3:24 AM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default β ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default β ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
[feature] class properties that are "readonly in public, writable in private" or other permutations
<!-- π¨ STOP π¨ π¦π§π’π£ π¨ πΊπ»πΆπ· π¨ Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ, especially the "Common Feature Requests" section: https://github.com/Microsoft/TypeScript/wiki/FAQ --> ## Search Terms [typescript readonly on the outside writable on the inside](https://www.google.com/search?q=typescript%20readonly%20on%20the%20outside%20writable%20on%20the%20inside&cad=h) - https://stackoverflow.com/questions/46634876/how-can-i-change-a-readonly-property-in-typescript ## Suggestion Some sort of syntax to describe `readonly on the outside, writeable on the inside` for a given property, so we can avoid making a getter just for this purpose (or using any of the convoluted options linked in that StackOverflow post). ## Use Cases To make this pattern easier to express. ## Examples instead of having to write ```ts class Foo { private _foo = 123 get foo() { return this._foo } changeIt() { this._foo = 456 } } const f = new Foo f.foo = 345 // ERROR ``` we would be able to write something shorter like ```ts class Foo { publicread foo = 123 changeIt() { this.foo = 456 } } const f = new Foo f.foo = 345 // ERROR ``` ## Checklist My suggestion meets these guidelines: * [x] This wouldn't be a breaking change in existing Typ
Comments (0)
No comments yet. Start the discussion.