为什么编译器警报未定义?

时间:2019-12-11 03:29:31

标签: reactjs typescript

为什么编译器会这样说?

Argument of type '{ kind: "available"; | { kind: "notAvailable"; } | undefined' is not assignable to parameter of type 'Schedule'.
  Type 'undefined' is not assignable to type 'Schedule'.

绝对无法将'undefined'放入availableTimeShiftsByHoursTables

     let availableTimeShiftsByHoursTables: Schedule[] = new Array();
    scheduleInfo.map(element => {
      if (element.schedules.get(targetDate)) {
        availableTimeShiftsByHoursTables.push(
          element.schedules.get(targetDate)
        );
      }
    });

0 个答案:

没有答案
相关问题