diff --git a/lib/editor/components/timetable/CalendarSelect.js b/lib/editor/components/timetable/CalendarSelect.js index 1b9eca235..73ff815ec 100644 --- a/lib/editor/components/timetable/CalendarSelect.js +++ b/lib/editor/components/timetable/CalendarSelect.js @@ -7,7 +7,7 @@ import Select from 'react-select' import * as activeActions from '../../actions/active' import {entityIsNew} from '../../util/objects' -import type {Pattern, GtfsRoute, Feed, ServiceCalendar, ScheduleException, Trip, TripCounts} from '../../../types' +import type {Pattern, GtfsRoute, Feed, ServiceCalendar, ScheduleExceptionCalendar, Trip, TripCounts} from '../../../types' type CalendarOption = { calendar: ServiceCalendar, @@ -20,10 +20,10 @@ type CalendarOption = { } type Props = { - activeCalendar: ?ServiceCalendar, + activeCalendar: ?ServiceCalendar | ?ScheduleExceptionCalendar, activePattern: Pattern, calendars: Array, - exceptionBasedCalendars: Array, + exceptionBasedCalendars: ?Array, feedSource: Feed, route: GtfsRoute, setActiveEntity: typeof activeActions.setActiveEntity, diff --git a/lib/editor/util/timetable.js b/lib/editor/util/timetable.js index ed1bed610..e184fc206 100644 --- a/lib/editor/util/timetable.js +++ b/lib/editor/util/timetable.js @@ -51,7 +51,7 @@ export function parseTime (timeString: string) { } // Helper function to find and return the active calendar, be it traditional or exception-based. -export function getActiveCalendar (calendars: Array, exceptionBasedCalendars: Array, activeScheduleId: string) { +export function getActiveCalendar (calendars: Array, exceptionBasedCalendars: Array, activeScheduleId: string): ?ServiceCalendar | ?ScheduleExceptionCalendar { const activeCalendarFilter = c => c.service_id === activeScheduleId return calendars.find(activeCalendarFilter) || exceptionBasedCalendars.find(activeCalendarFilter) } diff --git a/lib/editor/util/validation.js b/lib/editor/util/validation.js index 05139406d..a94e23b6a 100644 --- a/lib/editor/util/validation.js +++ b/lib/editor/util/validation.js @@ -340,6 +340,7 @@ export function validate ( const calendars: Array = clone(getTableById(tableData, 'calendar')) // Check if service ID exists elsewhere + // $FlowFixMe: Array#some confuses flow it seems. if (entity.custom_schedule && calendars.some(c => c.service_id === entity.custom_schedule)) { const reason = messages('conflictingServiceId') valErrors.push(validationIssue(reason, messages('customServiceId')))