Typescript嵌套接口抛出错误

时间:2018-07-13 14:55:49

标签: angular typescript

我有两个界面:

interface BarItem {
  planned: number;
  off: number;
  in: number;
  gdp_start: number;
  out: number;
  allocated: number;
}

interface BarData {
  max: number;
  title: string;
  tooltip: boolean;
  breaker: boolean;
  start_time: number;
  data: BarItem;
  linedata: number[];
}

这会在构建时引发以下错误:

ERROR in src/app/components/timeline-bar-graph/timeline-bar-graph.component.spec.ts(19,5): error TS2322: Type '{ max: number; title: string; tooltip: true; breaker: true; start_time: number; data: undefined[]...' is not assignable to type 'BarData'.
  Property 'linedata' is missing in type '{ max: number; title: string; tooltip: true; breaker: true; start_time: number; data: undefined[]...'.

0 个答案:

没有答案