cem-plugin-readonly
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

cem-plugin-readonly

Adds (non-standard) "readonly" flag to class fields

Example

custom-elements-manifest.config.js

import { readonlyPlugin } from 'cem-plugin-readonly';

export default {
  plugins: [
    readonlyPlugin(),
  ]
}

read-only.ts

/** @element read-only */
export class ReadOnly {
  static get x() { return 'x'; }
  static readonly y = 'y';
  /** @readonly */
  static z = 'z';
  readonly x = 'x';
  get y() { return 'y'; }
  /** @readonly */
  z = 'z';
}

Output

{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "read-only.js",
      "declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "ReadOnly",
          "members": [
            {
              "kind": "field",
              "name": "x",
              "readonly": true,
              "type": {
                "text": "string"
              }
            },
            {
              "kind": "field",
              "name": "y",
              "readonly": true,
              "type": {
                "text": "string"
              }
            },
            {
              "kind": "field",
              "name": "z",
              "readonly": true,
              "type": {
                "text": "string"
              }
            }
          ],
          "tagName": "read-only",
          "customElement": true
        }
      ],
      "exports": [
        {
          "kind": "js",
          "name": "ReadOnly",
          "declaration": {
            "name": "ReadOnly",
            "module": "read-only.js"
          }
        }
      ]
    }
  ]
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.5
    175
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.5
    175
  • 0.0.4
    0
  • 0.0.3
    0
  • 0.0.2
    14
  • 0.0.1
    0

Package Sidebar

Install

npm i cem-plugin-readonly

Weekly Downloads

189

Version

0.0.5

License

MIT

Unpacked Size

4.62 kB

Total Files

4

Last publish

Collaborators

  • bennyp