Which type ionchange event is?

Hi! I’m currently developing a PWA with Ionic v4 and Angular 6. I’m trying to reinforce typescript usage over my team, and while typing everything it struck me with a question: Which type does ionchange event belong? I couldn’t find it over the docs.

Also, I don’t know if it is a high impact question, but does the ionchange event type change over the different elements, or are they all the same?

Thanks! :smiley:

1 Like

Maybe type CustomEvent? when I have a look to https://github.com/ionic-team/ionic/blob/ca9ec3e18a2cd0a147556ebd7e2997fb1e833c49/angular/src/directives/proxies.ts the EventEmitter are declared with that type

In Ionic v3, it’s TextInput which you can use like

import { TextInput } from 'ionic-angular';

onMessageChange(change: TextInput): any {
...
}

Don’t think so, I think there isn’t a type TextInput in Ionic v4

p.s.: for references, no such results https://github.com/ionic-team/ionic/search?q=TextInput&unscoped_q=TextInput

Hm ok, I clarified the version. I’m using TextInput now in an Ionic v3 project just like above so I know it works there.

OP is building a PWA with Ionic v4 and looking for a v4 solution. ‘TextInput’ doesn’t exist in v4.

I use an ion-select and receive an object of type “CustomEvent” for (ionChange).

1 Like

For anyone looking for the answer for Ionic 5, I dug up the type in node/modules/@ionic/core/dist/components.d.ts

"onIonChange"?: (event: CustomEvent<SegmentChangeEventDetail>) => void;

Had to import it from ionic/core :

import { SegmentChangeEventDetail } from '@ionic/core/dist/types/interface';

For that, I had to to add ‘@ionic/core’ to my npm dependencies. So I don’t really know if it’s the right way to do do it…

And yes, it seems the type changes for every Component !

Hope this helps ! Cheers !

3 Likes