infer return type of functions

This commit is contained in:
Thomas Ruoff
2021-03-22 23:14:48 +01:00
parent 3cf2aff832
commit 9fe3fffb86
16 changed files with 54 additions and 54 deletions

View File

@@ -1,12 +1,12 @@
import * as mongoose from 'mongoose'
import BookerModel, { Booker } from './booker'
import BookingModel, { Booking } from './booking'
import BookingModel, { Booking, BookingDocument } from './booking'
import BillModel, { Bill } from './bill'
import { BOOKING_STATUS } from './enums'
let connectedPromise: Promise<typeof mongoose>
function connect() {
function connect(): Promise<typeof mongoose> {
if (connectedPromise) {
return
}
@@ -20,12 +20,12 @@ function connect() {
return connectedPromise
}
export async function getBookedDays(uuidsToIngore?: string[]) {
export async function getBookedDays(uuidsToIngore?: string[]): Promise<string[]> {
await connect()
return BookingModel.findBookedDays(uuidsToIngore)
}
export async function getBookingByUUID(uuid: string) {
export async function getBookingByUUID(uuid: string): Promise<BookingDocument> {
await connect()
return BookingModel.findOne({ uuid })
}
@@ -33,7 +33,7 @@ export async function getBookingByUUID(uuid: string) {
export async function getBookings({
status = [BOOKING_STATUS.CONFIRMED, BOOKING_STATUS.REQUESTED],
startDateGreaterThan = '2000-01-01T00:00:00Z',
}: { status?: BOOKING_STATUS[]; startDateGreaterThan?: string } = {}) {
}: { status?: BOOKING_STATUS[]; startDateGreaterThan?: string } = {}): Promise<BookingDocument[]> {
await connect()
return await BookingModel.find({
status: { $in: status },