Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Document auto-accessors in classes #3365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

mrazauskas
Copy link
Contributor

As I was mentioning on Discord, currently the handbook does not document auto-accessors. This feature was shipped with TypeScript 4.9, but it is still in Stage 3.

To put the text together, I used these sources:

@jakebailey
Copy link
Member

Should this mention "why" someone might want to do this? I.e. I think the relationship to decorators? Not that those are very documented, either.

@mrazauskas
Copy link
Contributor Author

Ah.. Right! Perhaps simply: less boiler plate code? This is exactly what is visible in the examples. Or?

@jakebailey
Copy link
Member

Well, the immediate question with this example would be "if it generates me a getter and a setter, why not use a prop"? So I would figure that there's some other reason for them.

@mrazauskas
Copy link
Contributor Author

why not use a prop

A prop is not a readonly field.

Of course, do I understand this isn’t a real world example. The aim is slightly different. Last week I saw the accessor keyword and I did not know what it is. Let’s read the docs, is the first thought. But there was nothing about that.

@mrazauskas
Copy link
Contributor Author

On second thought, this indeed sounds mostly useful in decorators context. So leaving it for the future.

@mrazauskas mrazauskas closed this Apr 8, 2025
@mrazauskas mrazauskas deleted the document-auto-accessors branch April 8, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants