-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
feat: extend CustomEvent types for ionic components #22925
Comments
Thanks, I think we could do this. Something like: interface InfiniteScrollEvent extends CustomEvent {
target: HTMLIonInfiniteScrollElement;
} for components that actually provide a payload (such as Searchbar): interface SearchbarEventDetail {
value: string | undefined;
}
interface SearchbarEvent extends CustomEvent {
target: HTMLIonSearchbarElement;
detail: SearchbarEventDetail;
} |
Sounds great! |
Also, I think this might be related. $event in angular is always of type when it's really of type @ProxyCmp({ inputs: ["allowEmptySelection", "name", "value"] })
@Component({ selector: "ion-radio-group", changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-content></ng-content>", inputs: ["allowEmptySelection", "name", "value"] })
export class IonRadioGroup {
ionChange!: EventEmitter<CustomEvent>; // <---- Emits CustomEvent not Event
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ["ionChange"]);
}
} So we need to change the type every time to make it work and set it to setBillingAddress(event : Event){
this.billingAddress = (event as CustomEvent).detail.value as Address;
} This is a related discussion from the community. |
Hi everyone, Here is a dev build of this new feature is anyone would like to test it out. Please note that this feature will be in Ionic v6 and the dev build is subject to the Ionic v6 Breaking Changes. For a list of all interfaces now available, please see #23956.
Angular
React
Vue
Stencil/Vanilla JavaScript
|
) resolves #22925 BREAKING CHANGE: The `RadioChangeEventDetail` interface has been removed in favor of `RadioGroupChangeEventDetail`.
Thanks for the issue. This has been added via #23956 and will be available in an upcoming Ionic 6 beta. Please feel free to test and leave feedback! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Feature Request
Create typing for Ionics various EventEmitter that extend ES CustomEvent.
Ionic version:
[x] 5.x
Describe the Feature Request
Right now if for example I want to safe type the event parameter passed to a callback function for the
ionInfinite
event emitter and I type it as CustomEvent, I get a ts compiler error as soon as I callevent.target.complete()
becausecomplete()
is not a valid method for the target object inCustomEvent
.As a fallback I have to type my passed event as
any
for it to work.Describe Preferred Solution
Create types for ionics various EventEmitter that extend ES CustomEvent.
Describe Alternatives
None
Related Code
Template:
Controller:
The text was updated successfully, but these errors were encountered: