JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
278 stars 25 forks source link

How to define events for components individually using V2 #57

Closed tolking closed 1 year ago

tolking commented 1 year ago

I found that the events defined in the V2 are global and do not support defining a component individually.

"js": {
      "events": [
        {
          "name": "test",
          "description": "test event"
        }
    ]
}

But if defined in a component like V1, it works fine but produces an error.

"html": {
      "elements": [
        {
          "name": "app-demo",
          "events": [ // Property 'events' is deprecated: Contribute events to JS namespace: /js/events
            {
              "name": "load",
              "description": "load more info",
            }
          ]
       }
    ]
}

I would like to ask how to define separate events for components now.

piotrtomiak commented 1 year ago

Each contribution accepts namespace contributions, so you can add js or css contributions within them. E.g.:

"html": {
  "elements": [
    {
      "name": "app-demo",
      "js": {
        "events": [
          {
            "name": "load",
            "description": "load more info"
          }
        ]
      }
    }
  ]
}

Please note that if you are writing web-types for Vue components, they should now be contributed to html/vue-components instead of html/elements.