Is there a more sophisticated method to cast day
as the correct type, rather than using (<{P: string}>day).P
without resorting to the generic any
type when dealing with a day
object obtained from underscore.js through the findWhere command?
Simply writing let period of day.P
triggers this error:
TS2339:Property 'P' does not exist on type '{}'.
let day = _.findWhere(this.availabilityDays, {D: moment($scope.model.BookDate).format('YYYY-MM-DD')});
this.$scope.BookingPeriods.splice(0);
for (let period of (<{P: string}>day).P) {
this.$scope.BookingPeriods.push(period);
}