Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

260
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda