2017-09-14 2 views

답변

0

컴파일러는으로 입력 할 때 seriesthis.options에 존재하는지 여부를 알 수 없습니다.

는 속성 (게으른 방법 아웃) 타이핑을 제거 당신도 할 수있는이 문제를 해결하려면 다음

class AppComponent { 

    options: any; 
} 

을 또는 당신은 컴파일러가 너무 this.options이 될 것입니다 직접 할당하여 개체의 유형을 추론하도록 할 수 있습니다

class AppComponent { 

    options = { 
     chart: { 
      zoomType: 'xy' 
     }, 
     series: ... 
     // ... 
    }; 
} 

또는 인터페이스에 options의 유형을 정의 : 올바르게 입력

interface Options { 
    series: any[], // Should be typed to the shape of a series instead of `any` 
    // and type other props like "chart", "title" 
} 
class AppComponent { 

    options: Options; 

    constructor() { 
     this.options = { 
      chart: { 
       zoomType: 'xy' 
      }, 
      series: ... 
      // ... 
     }; 
    } 
}