Browse Source
- Create type declarations in interfaces/absurd-sql.d.ts - Import and use proper QueryExecResult and SqlValue types - Add declarations for all required modules: - @jlongster/sql.js - absurd-sql - absurd-sql/dist/indexeddb-backend - absurd-sql/dist/indexeddb-main-thread - Ensure type safety for database operations This change resolves TypeScript errors about missing type declarations while maintaining proper type safety for database operations. The declarations are placed in the interfaces folder to match the project's type organization.pull/137/head
2 changed files with 10 additions and 75 deletions
@ -1,62 +0,0 @@ |
|||
import type { QueryExecResult as DbQueryExecResult, SqlValue } from "../database"; |
|||
|
|||
declare module "@jlongster/sql.js" { |
|||
interface SQL { |
|||
Database: new (path: string, options?: { filename: boolean }) => AbsurdSqlDatabase; |
|||
FS: { |
|||
mkdir: (path: string) => void; |
|||
mount: (fs: any, options: any, path: string) => void; |
|||
open: (path: string, flags: string) => any; |
|||
close: (stream: any) => void; |
|||
}; |
|||
register_for_idb: (fs: any) => void; |
|||
} |
|||
|
|||
interface AbsurdSqlDatabase { |
|||
exec: (sql: string, params?: unknown[]) => Promise<DbQueryExecResult[]>; |
|||
run: ( |
|||
sql: string, |
|||
params?: unknown[], |
|||
) => Promise<{ changes: number; lastId?: number }>; |
|||
} |
|||
|
|||
interface QueryExecResult { |
|||
columns: string[]; |
|||
values: unknown[][]; |
|||
} |
|||
|
|||
export default function initSqlJs(options?: { |
|||
locateFile?: (file: string) => string; |
|||
}): Promise<SQL>; |
|||
} |
|||
|
|||
declare module "absurd-sql" { |
|||
import { SQL } from "@jlongster/sql.js"; |
|||
|
|||
export class SQLiteFS { |
|||
constructor(fs: any, backend: any); |
|||
} |
|||
} |
|||
|
|||
declare module "absurd-sql/dist/indexeddb-backend" { |
|||
export default class IndexedDBBackend { |
|||
constructor(); |
|||
} |
|||
} |
|||
|
|||
declare module 'absurd-sql/dist/indexeddb-main-thread' { |
|||
export interface SQLiteOptions { |
|||
filename?: string; |
|||
autoLoad?: boolean; |
|||
debug?: boolean; |
|||
} |
|||
|
|||
export interface SQLiteDatabase { |
|||
exec: (sql: string, params?: any[]) => Promise<any>; |
|||
close: () => Promise<void>; |
|||
} |
|||
|
|||
export function initSqlJs(options?: any): Promise<any>; |
|||
export function createDatabase(options?: SQLiteOptions): Promise<SQLiteDatabase>; |
|||
export function openDatabase(options?: SQLiteOptions): Promise<SQLiteDatabase>; |
|||
} |
Loading…
Reference in new issue