custom-elements-manifest icon indicating copy to clipboard operation
custom-elements-manifest copied to clipboard

Add readonly flag to properties

Open bennypowers opened this issue 4 years ago • 3 comments

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."
},

bennypowers avatar Dec 17 '20 12:12 bennypowers

This could be even useful with CSS props.

aFarkas avatar Dec 18 '20 13:12 aFarkas

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 avatar Jun 26 '21 11:06 hsablonniere

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.

hsablonniere avatar Jun 28 '21 14:06 hsablonniere