S
S
Svyatoslav Khusamov2017-04-12 08:11:27
Angular
Svyatoslav Khusamov, 2017-04-12 08:11:27

Why does the TypeScript compiler swear at the absence of a class property, if this property is present in it?

Why does the TypeScript compiler swear at the absence of a class property, if this property is present in it?

Property 'path' does not exist on type 'TutorService'.

this.tutorServiceService.getTutorServices()
      .then(tutorServices => {
        tutorServices.find(s => `/service/${s.path}` == this.router.url) // Property 'path' does not exist on type 'TutorService'.
      });

This is where the getTutorServices() method comes from:
getTutorServices(): Promise<TutorService[]> {
    return this.http.get(this.url)
       .toPromise()
       .then(response => response.json().data as TutorService[])
       .catch(this.handleError);
  }

And the problematic class itself:
export class TutorService {
    id: number;
  title: string;
  menuTitle: string;
  sinosis: string;
  text: string;
  path: string; 
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Svyatoslav Khusamov, 2017-04-12
@khusamov

Weird. I reloaded Webpack (or rather the Angular2 compiler - ng) and the error no longer bothers me. How so???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question