Issue: Argument of type 'Event' is not assignable to parameter

Hello guys

I`m a new Ionic and this is my first topic.

We are updating our app here, and this issue is happening

We are receiving thismessage on html file

Issue: Argument of type ‘Event’ is not assignable to parameter of type ‘CustomEvent’.

import { Component, OnInit, OnDestroy } from '@angular/core';
import { MenuController } from '@ionic/angular';
import { SegmentChangeEventDetail } from '@ionic/core';
import { Subscription } from 'rxjs';
 
import { PlacesService } from '../places.service';
import { Place } from '../place.model';
import { AuthService } from '../../auth/auth.service';
 
@Component({
  selector: 'app-discover',
  templateUrl: './discover.page.html',
  styleUrls: ['./discover.page.scss']
})
export class DiscoverPage implements OnInit, OnDestroy {
  loadedPlaces: Place[];
  listedLoadedPlaces: Place[];
  relevantPlaces: Place[];
  private placesSub: Subscription;
 
  constructor(
    private placesService: PlacesService,
    private menuCtrl: MenuController,
    private authService: AuthService
  ) {}
 
  ngOnInit() {
    this.placesSub = this.placesService.places.subscribe(places => {
      this.loadedPlaces = places;
      this.relevantPlaces = this.loadedPlaces;
      this.listedLoadedPlaces = this.relevantPlaces.slice(1);
    });
  }
 
  onOpenMenu() {
    this.menuCtrl.toggle();
  }
 
  onFilterUpdate(event: CustomEvent<SegmentChangeEventDetail>) {
    if (event.detail.value === 'all') {
      this.relevantPlaces = this.loadedPlaces;
      this.listedLoadedPlaces = this.relevantPlaces.slice(1);
    } else {
      this.relevantPlaces = this.loadedPlaces.filter(
        place => place.userId !== this.authService.userId
      );
      this.listedLoadedPlaces = this.relevantPlaces.slice(1);
    }
  }
 
  ngOnDestroy() {
    if (this.placesSub) {
      this.placesSub.unsubscribe();
    }
  }
}
 


2

my ionic version is 6.16.3

Any hint how to solve this issue?

Thank you in advanced

Not sure on the specifics, but I’d start by checking here

onFilterUpdate(event: CustomEvent<SegmentChangeEventDetail>) {

I’d try first to just make that event: any just to see if that is where the issue starts.

Typically with the errors, you should be getting a line number and file where the error is coming from.

Hey mate, thank you for your reply.

No problem with the function

I remember that i set “strictTemplates”: False when create it. It`s works like a charm.

best regards

A much more narrowly-targeted way to deal with this issue is described here.

Thank`s ! Realy usefull !