From ea8cd354f05a8856614210876144d8b8aef5fb53 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 31 Oct 2022 14:28:53 -0400 Subject: [PATCH] typescript fixes --- helpers/lotOccupancyDB/getFeeCategories.js | 4 ++-- helpers/lotOccupancyDB/getFeeCategories.ts | 6 ++---- helpers/lotOccupancyDB/getLotStatusSummary.ts | 2 +- helpers/lotOccupancyDB/getLotTypeSummary.ts | 2 +- helpers/lotOccupancyDB/getLotTypes.ts | 2 +- helpers/lotOccupancyDB/getMaps.d.ts | 4 +--- helpers/lotOccupancyDB/getMaps.js | 2 +- helpers/lotOccupancyDB/getMaps.ts | 4 +--- helpers/lotOccupancyDB/getNextLotId.d.ts | 2 +- helpers/lotOccupancyDB/getNextLotId.ts | 2 +- helpers/lotOccupancyDB/getOccupancyTypeFields.ts | 2 +- helpers/lotOccupancyDB/getPastLotOccupancyOccupants.ts | 2 +- helpers/lotOccupancyDB/getPreviousLotId.d.ts | 2 +- helpers/lotOccupancyDB/getPreviousLotId.ts | 2 +- helpers/lotOccupancyDB/getReportData.d.ts | 2 +- helpers/lotOccupancyDB/getReportData.ts | 4 ++-- 16 files changed, 19 insertions(+), 25 deletions(-) diff --git a/helpers/lotOccupancyDB/getFeeCategories.js b/helpers/lotOccupancyDB/getFeeCategories.js index c95c966e..2d482a7e 100644 --- a/helpers/lotOccupancyDB/getFeeCategories.js +++ b/helpers/lotOccupancyDB/getFeeCategories.js @@ -59,7 +59,7 @@ export const getFeeCategories = (filters, options) => { expectedFeeCategoryOrderNumber += 1; if (updateOrderNumbers && feeCategory.orderNumber !== expectedFeeCategoryOrderNumber) { database - .prepare("update FeeCategories" + " set orderNumber = ?" + " where feeCategoryId = ?") + .prepare("update FeeCategories set orderNumber = ? where feeCategoryId = ?") .run(expectedFeeCategoryOrderNumber, feeCategory.feeCategoryId); feeCategory.orderNumber = expectedFeeCategoryOrderNumber; } @@ -84,7 +84,7 @@ export const getFeeCategories = (filters, options) => { expectedFeeOrderNumber += 1; if (fee.orderNumber !== expectedFeeOrderNumber) { database - .prepare("update Fees" + " set orderNumber = ?" + " where feeId = ?") + .prepare("update Fees set orderNumber = ? where feeId = ?") .run(expectedFeeOrderNumber, fee.feeId); fee.orderNumber = expectedFeeOrderNumber; } diff --git a/helpers/lotOccupancyDB/getFeeCategories.ts b/helpers/lotOccupancyDB/getFeeCategories.ts index 6398399e..5441638b 100644 --- a/helpers/lotOccupancyDB/getFeeCategories.ts +++ b/helpers/lotOccupancyDB/getFeeCategories.ts @@ -103,9 +103,7 @@ export const getFeeCategories = ( if (updateOrderNumbers && feeCategory.orderNumber !== expectedFeeCategoryOrderNumber) { database - .prepare( - "update FeeCategories" + " set orderNumber = ?" + " where feeCategoryId = ?" - ) + .prepare("update FeeCategories set orderNumber = ? where feeCategoryId = ?") .run(expectedFeeCategoryOrderNumber, feeCategory.feeCategoryId); feeCategory.orderNumber = expectedFeeCategoryOrderNumber; @@ -138,7 +136,7 @@ export const getFeeCategories = ( if (fee.orderNumber !== expectedFeeOrderNumber) { database - .prepare("update Fees" + " set orderNumber = ?" + " where feeId = ?") + .prepare("update Fees set orderNumber = ? where feeId = ?") .run(expectedFeeOrderNumber, fee.feeId); fee.orderNumber = expectedFeeOrderNumber; diff --git a/helpers/lotOccupancyDB/getLotStatusSummary.ts b/helpers/lotOccupancyDB/getLotStatusSummary.ts index 184ae955..54574717 100644 --- a/helpers/lotOccupancyDB/getLotStatusSummary.ts +++ b/helpers/lotOccupancyDB/getLotStatusSummary.ts @@ -18,7 +18,7 @@ export const getLotStatusSummary = (filters?: GetFilters): LotStatusSummary[] => }); let sqlWhereClause = " where l.recordDelete_timeMillis is null"; - const sqlParameters = []; + const sqlParameters: unknown[] = []; if (filters && filters.mapId) { sqlWhereClause += " and l.mapId = ?"; diff --git a/helpers/lotOccupancyDB/getLotTypeSummary.ts b/helpers/lotOccupancyDB/getLotTypeSummary.ts index 9a124132..73d3ddf9 100644 --- a/helpers/lotOccupancyDB/getLotTypeSummary.ts +++ b/helpers/lotOccupancyDB/getLotTypeSummary.ts @@ -18,7 +18,7 @@ export const getLotTypeSummary = (filters?: GetFilters): LotTypeSummary[] => { }); let sqlWhereClause = " where l.recordDelete_timeMillis is null"; - const sqlParameters = []; + const sqlParameters: unknown[] = []; if (filters && filters.mapId) { sqlWhereClause += " and l.mapId = ?"; diff --git a/helpers/lotOccupancyDB/getLotTypes.ts b/helpers/lotOccupancyDB/getLotTypes.ts index 6bbc4984..b0760d54 100644 --- a/helpers/lotOccupancyDB/getLotTypes.ts +++ b/helpers/lotOccupancyDB/getLotTypes.ts @@ -34,7 +34,7 @@ export const getLotTypes = (): recordTypes.LotType[] => { } lotType.lotTypeFields = getLotTypeFields( - lotType.lotTypeId, + lotType.lotTypeId as number, database ); diff --git a/helpers/lotOccupancyDB/getMaps.d.ts b/helpers/lotOccupancyDB/getMaps.d.ts index b07dfda9..bbc454fa 100644 --- a/helpers/lotOccupancyDB/getMaps.d.ts +++ b/helpers/lotOccupancyDB/getMaps.d.ts @@ -1,5 +1,3 @@ import type * as recordTypes from "../../types/recordTypes"; -interface GetMapsFilters { -} -export declare const getMaps: (filters?: GetMapsFilters) => recordTypes.Map[]; +export declare const getMaps: () => recordTypes.Map[]; export default getMaps; diff --git a/helpers/lotOccupancyDB/getMaps.js b/helpers/lotOccupancyDB/getMaps.js index 31018f9e..32578e61 100644 --- a/helpers/lotOccupancyDB/getMaps.js +++ b/helpers/lotOccupancyDB/getMaps.js @@ -1,6 +1,6 @@ import sqlite from "better-sqlite3"; import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js"; -export const getMaps = (filters) => { +export const getMaps = () => { const database = sqlite(databasePath, { readonly: true }); diff --git a/helpers/lotOccupancyDB/getMaps.ts b/helpers/lotOccupancyDB/getMaps.ts index 0d511bdc..a35f6208 100644 --- a/helpers/lotOccupancyDB/getMaps.ts +++ b/helpers/lotOccupancyDB/getMaps.ts @@ -4,9 +4,7 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js"; import type * as recordTypes from "../../types/recordTypes"; -interface GetMapsFilters {} - -export const getMaps = (filters?: GetMapsFilters): recordTypes.Map[] => { +export const getMaps = (): recordTypes.Map[] => { const database = sqlite(databasePath, { readonly: true }); diff --git a/helpers/lotOccupancyDB/getNextLotId.d.ts b/helpers/lotOccupancyDB/getNextLotId.d.ts index 70e82d2b..21c38756 100644 --- a/helpers/lotOccupancyDB/getNextLotId.d.ts +++ b/helpers/lotOccupancyDB/getNextLotId.d.ts @@ -1,2 +1,2 @@ -export declare const getNextLotId: (lotId: number | string) => number; +export declare const getNextLotId: (lotId: number | string) => number | undefined; export default getNextLotId; diff --git a/helpers/lotOccupancyDB/getNextLotId.ts b/helpers/lotOccupancyDB/getNextLotId.ts index 0372070c..aec0ae98 100644 --- a/helpers/lotOccupancyDB/getNextLotId.ts +++ b/helpers/lotOccupancyDB/getNextLotId.ts @@ -4,7 +4,7 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js"; import * as configFunctions from "../functions.config.js"; -export const getNextLotId = (lotId: number | string): number => { +export const getNextLotId = (lotId: number | string): number | undefined => { const database = sqlite(databasePath, { readonly: true }); diff --git a/helpers/lotOccupancyDB/getOccupancyTypeFields.ts b/helpers/lotOccupancyDB/getOccupancyTypeFields.ts index 04895b5d..22bd9bb5 100644 --- a/helpers/lotOccupancyDB/getOccupancyTypeFields.ts +++ b/helpers/lotOccupancyDB/getOccupancyTypeFields.ts @@ -10,7 +10,7 @@ export const getOccupancyTypeFields = ( ): recordTypes.OccupancyTypeField[] => { const database = connectedDatabase || sqlite(databasePath); - const sqlParameters = []; + const sqlParameters: unknown[] = []; if (occupancyTypeId) { sqlParameters.push(occupancyTypeId); diff --git a/helpers/lotOccupancyDB/getPastLotOccupancyOccupants.ts b/helpers/lotOccupancyDB/getPastLotOccupancyOccupants.ts index 762c5d32..b1fdbd0c 100644 --- a/helpers/lotOccupancyDB/getPastLotOccupancyOccupants.ts +++ b/helpers/lotOccupancyDB/getPastLotOccupancyOccupants.ts @@ -23,7 +23,7 @@ export const getPastLotOccupancyOccupants = ( let sqlWhereClause = " where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null"; - const sqlParameters = []; + const sqlParameters: unknown[] = []; if (filters.searchFilter) { const searchFilterPieces = filters.searchFilter.split(" "); diff --git a/helpers/lotOccupancyDB/getPreviousLotId.d.ts b/helpers/lotOccupancyDB/getPreviousLotId.d.ts index d218e2e5..5eaeab8c 100644 --- a/helpers/lotOccupancyDB/getPreviousLotId.d.ts +++ b/helpers/lotOccupancyDB/getPreviousLotId.d.ts @@ -1,2 +1,2 @@ -export declare const getPreviousLotId: (lotId: number | string) => number; +export declare const getPreviousLotId: (lotId: number | string) => number | undefined; export default getPreviousLotId; diff --git a/helpers/lotOccupancyDB/getPreviousLotId.ts b/helpers/lotOccupancyDB/getPreviousLotId.ts index 1e2e44ee..d0fff517 100644 --- a/helpers/lotOccupancyDB/getPreviousLotId.ts +++ b/helpers/lotOccupancyDB/getPreviousLotId.ts @@ -4,7 +4,7 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js"; import * as configFunctions from "../functions.config.js"; -export const getPreviousLotId = (lotId: number | string): number => { +export const getPreviousLotId = (lotId: number | string): number | undefined => { const database = sqlite(databasePath, { readonly: true }); diff --git a/helpers/lotOccupancyDB/getReportData.d.ts b/helpers/lotOccupancyDB/getReportData.d.ts index bd606ff9..b9d7ae7f 100644 --- a/helpers/lotOccupancyDB/getReportData.d.ts +++ b/helpers/lotOccupancyDB/getReportData.d.ts @@ -1,5 +1,5 @@ export interface ReportParameters { [parameterName: string]: string | number; } -export declare const getReportData: (reportName: string, reportParameters?: ReportParameters) => unknown[]; +export declare const getReportData: (reportName: string, reportParameters?: ReportParameters) => unknown[] | undefined; export default getReportData; diff --git a/helpers/lotOccupancyDB/getReportData.ts b/helpers/lotOccupancyDB/getReportData.ts index 5f117fd9..4a04357a 100644 --- a/helpers/lotOccupancyDB/getReportData.ts +++ b/helpers/lotOccupancyDB/getReportData.ts @@ -38,9 +38,9 @@ const occupancyEndDateAlias = occupancyCamelCase + "EndDate"; export const getReportData = ( reportName: string, reportParameters?: ReportParameters -): unknown[] => { +): unknown[] | undefined => { let sql: string; - const sqlParameters = []; + const sqlParameters: unknown[] = []; switch (reportName) { case "maps-all": {