Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
Typescript Angular - Recieving Type is missing following properties from type

So I'm trying to setup a model and keep getting the mentioned area. Screenshots attached show my syntax - I assumed it was an error from not passing the 'name' , 'amount' but in my array I give two new values with both of those.

EDIT - Can' post images so code below.

  ingredients: Ingredient = [
new Ingredient ('Apples', 5),
new Ingredient ('Tomatos', 10)];
export class Ingredient{

constructor(public name: string, public amount: number){ }}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The way you're declaring it "ingredients" variable should be an ingredient and not an array/list of ingredients.

So:

const ingredient: Ingredient = new Ingredient ('Apples', 5)

or

const ingredients: Ingredient[] = [
  new Ingredient ('Apples', 5),
  new Ingredient ('Tomatos', 10)
];

To specify an array type you can also use:

const ingredients: Array<Ingredient> = [...]
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda