lundi 28 août 2017

Property 'prototype' is missing in type 'MyObject'

I want to write a web-application on Webstorm with Angular2. I am very new on do this. I am trying the tutorial on the angular website Angular.IO.

When I try to make a list of Person clickable, it is not working.

export class PersonComponent {
 persons = MYPERSONS;
 selectedPersons = Person;

 onSelect(person: Person): void {
  this.selectedPerson = person;   // here is the error on "this.selectedPerson"
 }
}

const MYPERSONS: Person[] = [
 {id:0, firstName: 'First', lastName: 'Firstly', creationData: 1},
 {id:1, firstName: 'Second', lastName: 'Test', creationData:10},
 {id:2, firstName: 'Third', lastName: 'Candidate', creationData:5}
];

export class Person {
 id: number;
 firstName: string;
 lastName: string;
 creationData: any;
}

I get the following error:

Type 'Person' is not assignable to type 'typeof Person'. Property 'prototype' is missing in type 'Person'.

What does it mean? I can't find this error on the internet. It is probably anything what I'm not seeing on the code because of my few experience




Aucun commentaire:

Enregistrer un commentaire