TypeScript + Angular: Property is missing in type [2322]

0

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

Thisistheerror,butIdonotknowwhatiswrongbecauseitlooksliketheconstructoroftheuser.modelclassthatfollows.

Where did this 'Name' property come from, which I can not see? I'm sorry if I made a mistake, it's my second post here.

    
asked by anonymous 08.12.2018 / 06:51

1 answer

2

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

Follow the code below:

export class Usuario{
    private _nome: string;

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

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