{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2845","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2845/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2845/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2845/events","html_url":"https://github.com/Microsoft/TypeScript/issues/2845","id":69789050,"number":2845,"title":"Different access modifier for getter and setter","user":{"login":"Andree643","id":6212595,"avatar_url":"https://avatars0.githubusercontent.com/u/6212595?v=4","gravatar_id":"","url":"https://api.github.com/users/Andree643","html_url":"https://github.com/Andree643","followers_url":"https://api.github.com/users/Andree643/followers","following_url":"https://api.github.com/users/Andree643/following{/other_user}","gists_url":"https://api.github.com/users/Andree643/gists{/gist_id}","starred_url":"https://api.github.com/users/Andree643/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andree643/subscriptions","organizations_url":"https://api.github.com/users/Andree643/orgs","repos_url":"https://api.github.com/users/Andree643/repos","events_url":"https://api.github.com/users/Andree643/events{/privacy}","received_events_url":"https://api.github.com/users/Andree643/received_events","type":"User","site_admin":false},"labels":[{"id":117630901,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Declined","name":"Declined","color":"556677","default":false},{"id":113971155,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75","default":false},{"id":117630959,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Too%20Complex","name":"Too Complex","color":"556677","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2015-04-21T09:02:02Z","updated_at":"2018-02-11T11:57:08Z","closed_at":"2016-01-29T22:07:07Z","author_association":"NONE","body":"Could it be possible to implement different access modifier for getter and setter? This way the setter could be for example private/protected and the getter public. In some cases this in really useful when the value shall be read-only.\n\nExample:\n\n```\nclass MyClass {\n    private _myProp: any;\n    private set myProp(value: any) {\n        this._myProp = value;\n    }\n    public get myProp(): any {\n        return this._myProp;\n    }\n}\n```\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/364746033","html_url":"https://github.com/Microsoft/TypeScript/issues/2845#issuecomment-364746033","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2845","id":364746033,"user":{"login":"mdarefull","id":22510674,"avatar_url":"https://avatars3.githubusercontent.com/u/22510674?v=4","gravatar_id":"","url":"https://api.github.com/users/mdarefull","html_url":"https://github.com/mdarefull","followers_url":"https://api.github.com/users/mdarefull/followers","following_url":"https://api.github.com/users/mdarefull/following{/other_user}","gists_url":"https://api.github.com/users/mdarefull/gists{/gist_id}","starred_url":"https://api.github.com/users/mdarefull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdarefull/subscriptions","organizations_url":"https://api.github.com/users/mdarefull/orgs","repos_url":"https://api.github.com/users/mdarefull/repos","events_url":"https://api.github.com/users/mdarefull/events{/privacy}","received_events_url":"https://api.github.com/users/mdarefull/received_events","type":"User","site_admin":false},"created_at":"2018-02-11T11:57:08Z","updated_at":"2018-02-11T11:57:08Z","author_association":"NONE","body":"I've been reading you guys claiming it is too complex. Remembering the \"C++ way\" why it is different from:\r\n```\r\nprivate _myAttribute: string;\r\nget myAttribute(): string {...}\r\nsetMyAttribute(value: string) {...}\r\n```\r\n\r\nI can see a lot of use cases for this, that's why I'm here right now. \r\nWhat if I want myAttribute to be publicly accessible but allow only to be modified inside its class? \r\nWhat if I want to add some custom logic each time the attribute is modified? \r\nIt can be a business rule, it can be just a logging to understand why it has been assigned a specific value, together with a breakpoint condition for debugging purposes, etc...\r\n\r\nBasically, we want a method to be used each time we modify the attribute together with the syntactic sugar that makes it seems we're just assigning a value, instead than calling a method.\r\nC# has the concept of properties for this and I thought TS inherited that concept, but not allowing different accessibilities is a big limitations for people that think like me and make us fall back to the \"C++ style\"."}}
{"actor":{"display_login":"mdarefull"}}