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

[typedoc-plugin-markdown@next] Partially generating events #534

Closed
CoderIllusionist opened this issue Jan 4, 2024 · 11 comments
Closed

[typedoc-plugin-markdown@next] Partially generating events #534

CoderIllusionist opened this issue Jan 4, 2024 · 11 comments
Labels
next Fix available in the '@next' release

Comments

@CoderIllusionist
Copy link

CoderIllusionist commented Jan 4, 2024

Hi,

Given the following interface;

    interface SimpleComponent {
        /**
          * bla description
         */
        "open"?: boolean;
        /**
          * bla description
          * @eventProperty
          * @deprecated - bla bla
         */
        "onBstToggle"?: (event: BstSimpleComponentCustomEvent<MouseEvent>) => void;
    }

Will resolve to

| Property | Type | Description |
| :------ | :------ | :------ |
| `open?` | `boolean` | bla description |

## Events

| Property | Type | Description |
| :------ | :------ | :------ |
| `onToggleExpansionPanel?` | (`event`) => `void` | - |

***

As you can see the description is empty and it doesn't take @deprecated into account. Any idea how to fix that ? The interface itself is generated by StencilJS.

P.S. when not adding the @eventProperty it wont register an event

@tgreyuk tgreyuk added the next Fix available in the '@next' release label Jan 5, 2024
@tgreyuk
Copy link
Member

tgreyuk commented Jan 5, 2024

Thanks - issues should be fixed when using typedoc 0.25.6 and typedoc-plugin-markdown 4.0.0-next.39.

@CoderIllusionist
Copy link
Author

Thanks, closing.

@CoderIllusionist
Copy link
Author

@tgreyuk i didn't noticed it earlier, but i noticed it always generates (event) => void without the actual typing. BstSimpleComponentCustomEvent contains an detail and target

@tgreyuk
Copy link
Member

tgreyuk commented Jan 23, 2024

ok - i'll re-open and investigate...

@tgreyuk tgreyuk reopened this Jan 23, 2024
@CoderIllusionist
Copy link
Author

FYI - here's the type decleration file generated by stencil for reference;

/* eslint-disable */
/* tslint:disable */
/**
 * This is an autogenerated file created by the Stencil compiler.
 * It contains typing information for all components that exist in this project.
 */
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { InputValues } from "./components/my-component/my-component";
export { InputValues } from "./components/my-component/my-component";
export namespace Components {
    interface MyComponent {
        /**
          * The first name
         */
        "first": string;
        /**
          * The last name
         */
        "last": string;
        /**
          * The middle name
         */
        "middle": string;
    }
}
export interface MyComponentCustomEvent<T> extends CustomEvent<T> {
    detail: T;
    target: HTMLMyComponentElement;
}
declare global {
    interface HTMLMyComponentElementEventMap {
        "inputEvent": InputValues;
    }
    interface HTMLMyComponentElement extends Components.MyComponent, HTMLStencilElement {
        addEventListener<K extends keyof HTMLMyComponentElementEventMap>(type: K, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<HTMLMyComponentElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
        removeEventListener<K extends keyof HTMLMyComponentElementEventMap>(type: K, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<HTMLMyComponentElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
    }
    var HTMLMyComponentElement: {
        prototype: HTMLMyComponentElement;
        new (): HTMLMyComponentElement;
    };
    interface HTMLElementTagNameMap {
        "my-component": HTMLMyComponentElement;
    }
}
declare namespace LocalJSX {
    interface MyComponent {
        /**
          * The first name
         */
        "first"?: string;
        /**
          * The last name
         */
        "last"?: string;
        /**
          * The middle name
         */
        "middle"?: string;
        /**
          * A input event
         */
        "onInputEvent"?: (event: MyComponentCustomEvent<InputValues>) => void;
    }
    interface IntrinsicElements {
        "my-component": MyComponent;
    }
}
export { LocalJSX as JSX };
declare module "@stencil/core" {
    export namespace JSX {
        interface IntrinsicElements {
            "my-component": LocalJSX.MyComponent & JSXBase.HTMLAttributes<HTMLMyComponentElement>;
        }
    }
}

We use LocalJSX namespace and ignore documentation generated for the namespace Components

Source code:

import { Component, Prop, h, Event, EventEmitter } from '@stencil/core';
import { format } from '../../utils/utils';

export type InputValue = undefined | null | boolean | string | number | string[] | Date;

export type InputValues<V = InputValue> = { value: V; oldValue: V };

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css',
  shadow: true,
})
export class MyComponent {
  /**
   * The first name
   */
  @Prop() first: string;

  /**
   * The middle name
   */
  @Prop() middle: string;

  /**
   * The last name
   */
  @Prop() last: string;

  /**
   * A input event
   */
  @Event() inputEvent:  EventEmitter<InputValues>

  private getText(): string {
    return format(this.first, this.middle, this.last);
  }

  render() {
    return <div>Hello, World! I'm {this.getText()}</div>;
  }
}

@CoderIllusionist
Copy link
Author

Hi, any update on this, can I help in any way?

@tgreyuk
Copy link
Member

tgreyuk commented Feb 6, 2024

I did update so the param type is displayed in the signature but not sure if this is sufficient. What would be really useful though is an example repo to test against.

@CoderIllusionist
Copy link
Author

@tgreyuk I created a repo; https://stackblitz.com/github/CoderIllusionist/typedoc-plugin-demo

It's already fixed indeed, just made the example repo so you could check it. I noticed that the sort typedoc options doesn't work entirely for the properties / events? let me know if i need to create a separate issue for this, you can see the sorting in the demo.

@tgreyuk
Copy link
Member

tgreyuk commented Feb 9, 2024

@CoderIllusionist thanks for putting the repo together - that is super useful.

So this is an interesting one. The entry point in this case is a d.ts file generated by stencil which has already been sorted alphbetically. So infact source-order is behaving correctly in this instance:

Screenshot 2024-02-09 at 18 03 59

@CoderIllusionist
Copy link
Author

CoderIllusionist commented Feb 9, 2024

No problem :). Yes indeed, I noticed that after I posted the comment, my bad 😃 . For us the events are fixed, you can close this issue if you want to, I'll try to keep the example repo up and running if you need it.

@tgreyuk
Copy link
Member

tgreyuk commented Feb 9, 2024

Ok thanks @CoderIllusionist i will close this one. All this feedback is appreciated and obviously please do continue raising new issues as you find stuff.

@tgreyuk tgreyuk closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Fix available in the '@next' release
Projects
None yet
Development

No branches or pull requests

2 participants