forked from trent_larson/crowd-funder-for-time-pwa
refactor: add strict types to PlatformServiceMixin interfaces
- Replace all `any` types in IPlatformServiceMixin and ComponentCustomProperties with proper types: - Use PlatformCapabilities for capabilities - Use QueryExecResult, DatabaseExecResult, and generics for database methods - Use Contact[] and Settings for contact and settings methods - Improves IDE type inference and type safety for all consumers of the mixin - No functional changes, interface/type declarations only
This commit is contained in:
@@ -35,7 +35,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||||
import type { PlatformService } from "@/services/PlatformService";
|
import type {
|
||||||
|
PlatformService,
|
||||||
|
PlatformCapabilities,
|
||||||
|
} from "@/services/PlatformService";
|
||||||
import { mapColumnsToValues, parseJsonField } from "@/db/databaseUtil";
|
import { mapColumnsToValues, parseJsonField } from "@/db/databaseUtil";
|
||||||
import { MASTER_SETTINGS_KEY, type Settings } from "@/db/tables/settings";
|
import { MASTER_SETTINGS_KEY, type Settings } from "@/db/tables/settings";
|
||||||
import * as databaseUtil from "@/db/databaseUtil";
|
import * as databaseUtil from "@/db/databaseUtil";
|
||||||
@@ -671,9 +674,12 @@ export const PlatformServiceMixin = {
|
|||||||
*/
|
*/
|
||||||
export interface IPlatformServiceMixin {
|
export interface IPlatformServiceMixin {
|
||||||
platformService: PlatformService;
|
platformService: PlatformService;
|
||||||
$dbQuery(sql: string, params?: unknown[]): Promise<any>;
|
$dbQuery(
|
||||||
$dbExec(sql: string, params?: unknown[]): Promise<any>;
|
sql: string,
|
||||||
$dbGetOneRow(sql: string, params?: unknown[]): Promise<any>;
|
params?: unknown[],
|
||||||
|
): Promise<QueryExecResult | undefined>;
|
||||||
|
$dbExec(sql: string, params?: unknown[]): Promise<DatabaseExecResult>;
|
||||||
|
$dbGetOneRow(sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
|
||||||
$getSettings(
|
$getSettings(
|
||||||
key: string,
|
key: string,
|
||||||
fallback?: Settings | null,
|
fallback?: Settings | null,
|
||||||
@@ -687,7 +693,7 @@ export interface IPlatformServiceMixin {
|
|||||||
isCapacitor: boolean;
|
isCapacitor: boolean;
|
||||||
isWeb: boolean;
|
isWeb: boolean;
|
||||||
isElectron: boolean;
|
isElectron: boolean;
|
||||||
capabilities: any;
|
capabilities: PlatformCapabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeScript declaration merging to eliminate (this as any) type assertions
|
// TypeScript declaration merging to eliminate (this as any) type assertions
|
||||||
@@ -698,7 +704,7 @@ declare module "@vue/runtime-core" {
|
|||||||
isCapacitor: boolean;
|
isCapacitor: boolean;
|
||||||
isWeb: boolean;
|
isWeb: boolean;
|
||||||
isElectron: boolean;
|
isElectron: boolean;
|
||||||
capabilities: any;
|
capabilities: PlatformCapabilities;
|
||||||
|
|
||||||
// Ultra-concise database methods (shortest possible names)
|
// Ultra-concise database methods (shortest possible names)
|
||||||
$db(sql: string, params?: unknown[]): Promise<QueryExecResult | undefined>;
|
$db(sql: string, params?: unknown[]): Promise<QueryExecResult | undefined>;
|
||||||
@@ -716,9 +722,15 @@ declare module "@vue/runtime-core" {
|
|||||||
): Promise<T | null>;
|
): Promise<T | null>;
|
||||||
|
|
||||||
// Enhanced utility methods
|
// Enhanced utility methods
|
||||||
$dbQuery(sql: string, params?: unknown[]): Promise<any>;
|
$dbQuery(
|
||||||
$dbExec(sql: string, params?: unknown[]): Promise<any>;
|
sql: string,
|
||||||
$dbGetOneRow(sql: string, params?: unknown[]): Promise<any>;
|
params?: unknown[],
|
||||||
|
): Promise<QueryExecResult | undefined>;
|
||||||
|
$dbExec(sql: string, params?: unknown[]): Promise<DatabaseExecResult>;
|
||||||
|
$dbGetOneRow(
|
||||||
|
sql: string,
|
||||||
|
params?: unknown[],
|
||||||
|
): Promise<unknown[] | undefined>;
|
||||||
$getSettings(
|
$getSettings(
|
||||||
key: string,
|
key: string,
|
||||||
defaults?: Settings | null,
|
defaults?: Settings | null,
|
||||||
|
|||||||
Reference in New Issue
Block a user