无法成功编译我的角度应用程序

时间:2018-12-11 18:23:27

标签: angular typescript import compiler-errors export

我有一个名为mock-values.ts的文件,它只有:

export const TIMES: Time[] = [
  { i: '8:00', v: '8' }, { i: '8:30', v: '8:30' },
  { i: '9:00', v: '9' }, { i: '9:30', v: '9:30' },
  { i: '10:00', v: '10' }, { i: '10:30', v: '10:30' },
  { i: '11:00', v: '11' }
];
export const MINUTES: Minute[] = [
  { half_hour: '30' },
  { half_hour: '60' },
  { half_hour: '90' }
];

运行ng服务时,遇到此错误消息ERROR in src/app/meeting-form/mock-values.ts(1,21): error TS2304: Cannot find name 'Time'. src/app/meeting-form/mock-values.ts(13,23): error TS2304: Cannot find name 'Minute'.

这是我在form.component.ts

中的导入
import { TIMES, MINUTES } from './mock-values';
  times = TIMES;
  minutes = MINUTES;

大约一分钟后,它成功编译,因为最终找到了它。有什么办法告诉Angular放松一下或使编译器的过程更容易吗?

1 个答案:

答案 0 :(得分:1)

类似“时间”和“分钟”的外观不是预定义的类型。请尝试如下更改代码:

export const TIMES = [
  { i: '8:00', v: '8' }, { i: '8:30', v: '8:30' },
  { i: '9:00', v: '9' }, { i: '9:30', v: '9:30' },
  { i: '10:00', v: '10' }, { i: '10:30', v: '10:30' },
  { i: '11:00', v: '11' }
];
export const MINUTES = [
  { half_hour: '30' },
  { half_hour: '60' },
  { half_hour: '90' }
];