Typescript+Angular: Property is Missing in type [2322]

Asked

Viewed 257 times

0

I’m having a user mock problem that I’m doing on TS, it’s my first site in life and I’m kind of lost with some mistakes. I end up wasting hours trying to solve simple mistakes

Meu erro

This is the error, but I don’t know what’s wrong because it looks the same as the constructor of the user.model class that follows below.

inserir a descrição da imagem aqui

Where did this Property 'Nome' come from that I’m not seeing? I’m sorry if I missed something, it’s my second post here only.

1 answer

2


Typescript is Javascript only typed, when you create a user-type array, you need to fill in user-type objects.

Follows excerpt from the code below:

export class Usuario{
    private _nome: string;

    constructor(nome: string){
       _nome = nome;
    }
}

const USUARIO: Array<Usuario> = [
    new Usuario("teste"),
    new Usuario("teste2")
];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.