runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
500 stars 61 forks source link

CustomEvent type information not output as expected #248

Open gavinbarron opened 1 year ago

gavinbarron commented 1 year ago

Hi, Thanks for this really useful library, I'm part of the team working on Microsoft Graph Toolkit. We're currently using web component analyzer to help us build our React wrapper library @microsoft/mgt-react

We're looking to improve the developer experience for consumers of our web components by adding the information to the Generic types used when emitting CustomEvents, I found #169 and the linked playground which looks exactly like what we need, so it might be that #157 will resolve this?

I experimented with both 1.1.6 and 2.0.0-next.4 and got the same result in my trials to get better type information.

Given the jsdoc comment fragment on a web component:

* @fires {CustomEvent<IDynamicPerson[]>} selectionChanged - Fired when set of selected people changes

I get varying output depending on the output type with a loss of fidelity that is problematic for our scenario. Markdown:

| Event              | Type                            | Description                               |
|--------------------|---------------------------------|-------------------------------------------|
| `selectionChanged` | `CustomEvent<IDynamicPerson[]>` | Fired when set of selected people changes |

json2

"events": [
  {
    "description": "Fired when set of selected people changes",
    "name": "selectionChanged",
    "type": "CustomEvent"
  },

The type that is present in the md output is exactly what I'd expect to be provided when producing json2 output