forked from jsnbuchanan/crowd-funder-for-time-pwa
Integrate TypeScript type checking into build process with conditional execution
- Add type checking to build scripts for production/test builds only - Fix TypeScript errors in migration service, router, and platform services - Add electronAPI type declarations for Electron platform - Remove type checking from development builds for faster hot reload - Update tsconfig.node.json to resolve configuration conflicts - Ensure type safety for production while maintaining fast development workflow
This commit is contained in:
@@ -131,7 +131,7 @@ const MIGRATIONS = [
|
||||
* @param extractMigrationNames - A function that extracts the names (string array) from "select name from migrations"
|
||||
*/
|
||||
export async function runMigrations<T>(
|
||||
sqlExec: (sql: string, params?: unknown[]) => Promise<unknown>,
|
||||
sqlExec: (sql: string, params?: unknown[]) => Promise<void>,
|
||||
sqlQuery: (sql: string, params?: unknown[]) => Promise<T>,
|
||||
extractMigrationNames: (result: T) => Set<string>,
|
||||
): Promise<void> {
|
||||
|
||||
@@ -79,7 +79,7 @@ window.addEventListener("unhandledrejection", (event) => {
|
||||
});
|
||||
|
||||
// Electron-specific initialization
|
||||
if (typeof window !== "undefined" && window.require) {
|
||||
if (typeof window !== "undefined" && typeof window.require === "function") {
|
||||
// We're in an Electron renderer process
|
||||
logger.log("[Electron] Detected Electron renderer process");
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ router.onError(errorHandler); // Assign the error handler to the router instance
|
||||
* @param from - Source route
|
||||
* @param next - Navigation function
|
||||
*/
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
router.beforeEach(async (to, _from, next) => {
|
||||
try {
|
||||
// Skip identity check for routes that handle identity creation manually
|
||||
const skipIdentityRoutes = [
|
||||
|
||||
@@ -134,7 +134,11 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
||||
|
||||
// An error is thrown without this pragma: "File has invalid page size. (the first block of a new file must be written first)"
|
||||
await this.db.exec(`PRAGMA journal_mode=MEMORY;`);
|
||||
const sqlExec = this.db.run.bind(this.db);
|
||||
|
||||
// Create wrapper functions that match the expected signatures
|
||||
const sqlExec = async (sql: string, params?: unknown[]): Promise<void> => {
|
||||
await this.db!.run(sql, params);
|
||||
};
|
||||
const sqlQuery = this.db.exec.bind(this.db);
|
||||
|
||||
// Extract the migration names for the absurd-sql format
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
SQLiteConnection,
|
||||
SQLiteDBConnection,
|
||||
CapacitorSQLite,
|
||||
capSQLiteChanges,
|
||||
DBSQLiteValues,
|
||||
} from "@capacitor-community/sqlite";
|
||||
|
||||
@@ -496,19 +495,17 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
const sqlExec = async (
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
): Promise<capSQLiteChanges> => {
|
||||
): Promise<void> => {
|
||||
logger.debug(`🔧 [CapacitorMigration] Executing SQL:`, sql);
|
||||
|
||||
if (params && params.length > 0) {
|
||||
// Use run method for parameterized queries (prepared statements)
|
||||
// This is essential for proper parameter binding and SQL injection prevention
|
||||
const result = await this.db!.run(sql, params);
|
||||
return result;
|
||||
await this.db!.run(sql, params);
|
||||
} else {
|
||||
// Use execute method for non-parameterized queries
|
||||
// This is more efficient for simple DDL statements
|
||||
const result = await this.db!.execute(sql);
|
||||
return result;
|
||||
await this.db!.execute(sql);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
13
src/types/electron.d.ts
vendored
Normal file
13
src/types/electron.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI?: {
|
||||
exportData: (fileName: string, content: string) => Promise<{
|
||||
success: boolean;
|
||||
path?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in New Issue
Block a user