Closed adoumas closed 11 months ago
👋 can you provide a reproduction app/stencil project that experiences this problem?
We use the output target with Ionic Framework and the events are bound correctly. The outputs
array will not be written if the component does not have any decorated @Event()
properties.
Thanks for the issue! This issue has been labeled as needs reproduction
. This label is added to issues that need a code reproduction.
Please reproduce this issue in a Stencil project and provide a way for us to access it (GitHub repo, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.
If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.
A workaround to this issue that I've used is to define a HTMLElementTagNameMap
where I define event listeners for each Event:
/** src/my-types.d.ts */
declare global {
type EventName = "my-event";
interface HTMLMyComponentElement {
addEventListener<EventName>(type: EventName, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<boolean>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<EventName>(type: EventName, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<boolean>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
interface HTMLElementTagNameMap {
"my-component": HTMLMyComponentElement;
}
}
I've created a PR to make this part of Stencil's compiler: https://github.com/ionic-team/stencil/pull/4909 And you can use this output target to generate these event listener types for your project: https://github.com/m-thompson-code/event-listener-types-output-target#event-listener-types-output-target
Thanks for the issue! This issue is being closed due to the lack of a code reproduction. If this is still an issue with the latest version of the output targets, please create a new issue and ensure the template is fully filled out.
Prerequisites
Stencil Version
3.4.1
Stencil Framework Output Target
Angular
Stencil Framework Output Target Version
0.8.2
Current Behavior
At "generate-angular-component.ts" file line 47
` @Component({
selector: '${tagName}', changeDetection: ChangeDetectionStrategy.OnPush, template: ' ',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: [${formattedInputs}], ${standaloneOption}
}) `
and on line 29
`
`
Expected Behavior
Should be like this so we can use it on angular as event (myCustomEvent)="handleCustomEvent($event)"
` @Component({
selector: '${tagName}', changeDetection: ChangeDetectionStrategy.OnPush, template: ' ',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: [${formattedInputs}],
outputs: [${formattedOutputs}],
${standaloneOption},
}) `
`
`
Steps to Reproduce
Just try to build angularOutputTarget
Code Reproduction URL
https://github.com/ionic-team/stencil-ds-output-targets/blob/main/packages/angular-output-target/src/generate-angular-component.ts
Additional Information
I hope not to miss something and i can't use the output decorator
<my-custom-element (myCustomEvent)=""></my-custom-element>