Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
error TS2345: Argument of type 'Event' is not assignable to parameter of type 'IPokemon'

Running this code :

 <app-pokemon-form *ngIf="showPokemonForm" (newPokemonEvent)="addNewPokemon($event)" 
    (pokemonFormClose)="pokemonFormClose($event)"
      [pokemon]="currentPokemon"></app-pokemon-form>

Causes an error :

error TS2345: Argument of type 'Event' is not assignable to parameter of type 'IPokemon'.

Here is the TypeScript File:

 addNewPokemon(newPokemon: IPokemon): void {
    console.log('adding new pokemon ' + JSON.stringify(newPokemon));
    this.pokemonService.addPokemon({ ...newPokemon })
      .subscribe({
        next: pokemon => {
          console.log(JSON.stringify(pokemon) + ' has been added');
          this.message = "new pokemon has been added";
        },
        error: (err) => this.message = err
      });

And here is the pokemon model itself:

export interface IPokemon {
    _id: string,
    Name: string,
    Generation: Number,
    Type: string
}

Any Help Would Be Greatly Appreciated

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since your argument $event is of type Event, meaning it does not (necessarily) have the form of

interface IPokemon {
  _id: string,
  Name: string,
  Generation: number,
  Type: string
}

you cannot pass $event to your addPokemon method.

You can check the form of the $event parameter if it matches with the IPokemon interface and if

  • not: make sure that $event has the appropriate form, or
  • if yes: you can add $event as unknown as IPokemon in your function call
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!