Skip to content
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

Add readonly flag to properties #34

Closed
bennypowers opened this issue Dec 17, 2020 · 3 comments · Fixed by #118 · May be fixed by #92
Closed

Add readonly flag to properties #34

bennypowers opened this issue Dec 17, 2020 · 3 comments · Fixed by #118 · May be fixed by #92

Comments

@bennypowers
Copy link
Contributor

It would be helpful to mark a class field or property as readonly (i.e. getter only or defined as writable: false)

Screenshot_2020-12-17 Components apollo-client Apollo Elements

{
  "name": "elements",
  "type": "readonly ApolloElementElement[]",
  "readonly": true,
  "attribute": false,
  "summary": "List of all ApolloElements registered to this client."
},
@aFarkas
Copy link

aFarkas commented Dec 18, 2020

This could be even useful with CSS props.

@hsablonniere
Copy link

hsablonniere commented Jun 26, 2021

I have a map component and 2 marker components that expose 3 readonly properties, I used to annotate them like this:

/** @readonly */
this.size = [16, 16];
/** @readonly */
this.anchor = [8, 8];
/** @readonly */
this.tooltip = [0, 0];

@hsablonniere
Copy link

I decided to move those to getters (without setters) and I'll create a CEM analyzer plugin that used this "getter but no setter" to identify fields as readonly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants