fix most type errors

still have a few things outstanding
This commit is contained in:
Thomas Ruoff
2020-08-28 00:29:20 +02:00
committed by Thomas Ruoff
parent c3d8c6f3e0
commit 90ac05a907
16 changed files with 279 additions and 96 deletions

View File

@@ -4,7 +4,7 @@ import Booker from './booker'
import Booking from './booking'
import { BOOKING_STATUS } from './bookingStatus'
let connectedPromise
let connectedPromise: Promise<typeof mongoose>
function connect() {
if (connectedPromise) {
@@ -39,13 +39,13 @@ export async function getBookedDays() {
.sort()
}
export async function getBookingByUUID(uuid) {
export async function getBookingByUUID(uuid: string) {
await connect()
const booking = await Booking.findOne({ uuid })
return booking.populate('booker').execPopulate()
}
export async function getBookingByUUIDAsJSON(uuid) {
export async function getBookingByUUIDAsJSON(uuid: string) {
const booking = await getBookingByUUID(uuid)
return booking.toJSON()
}
@@ -66,7 +66,7 @@ export async function createBooking({
const booking = new Booking({ startDate, endDate, purpose, org, destination })
const bookedDays = await getBookedDays()
if (booking.days.some((day) => bookedDays.includes(day))) {
if (booking.days.some((day: string) => bookedDays.includes(day))) {
throw new mongoose.Error.ValidationError(booking)
}