Error Property 'Collection' does not exist on type 'Profile'

Asked

Viewed 120 times

0

There is the following variable declared in the script:

private profile: Profile;

See that it is a variable of type Profile.

When trying to assign a value to the variable, returns the following error:

Property 'Collection' does not exist on type 'Profile'.

The value being assigned is as follows:

this.profile = response.collection;

Meanwhile I found that the property response.collection is an instance of the class Profile:

console.log(response.collection instanceof Profile);
//true

Why the variable profile does not accept the value of response.collection where it is an instance of the class Profile?

  • like the response is tipado?

  • and please use the correct tag. Typescript is not used in Angularjs

  • @merchant regarding the tag was lapse on my part. Regarding typing I added the ":any" and it started to work, but I don’t understand the need to define the type for Sponse.

  • by the error message it seems to me that before Sponse was typed as Profile

  • @merchant the response no, but the response.collection yes, it is an instance of the class Profile.

No answers

Browser other questions tagged

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