Skip to content

fix: add transaction() to Database interface#584

Open
ductiletoaster wants to merge 1 commit intotobi:mainfrom
ductiletoaster:fix/database-transaction-type
Open

fix: add transaction() to Database interface#584
ductiletoaster wants to merge 1 commit intotobi:mainfrom
ductiletoaster:fix/database-transaction-type

Conversation

@ductiletoaster
Copy link
Copy Markdown

Problem

The custom Database interface in src/db.ts is missing the transaction() method. This causes a TypeScript compilation error when building from source:

src/store.ts(2142,22): error TS2339: Property 'transaction' does not exist on type 'Database'.

The published npm package works because it ships pre-built dist/ files. But building from a fresh git clone fails.

Fix

Add transaction() to the Database interface:

export interface Database {
  exec(sql: string): void;
  prepare(sql: string): Statement;
  transaction<T extends (...args: any[]) => any>(fn: T): T;  // added
  loadExtension(path: string): void;
  close(): void;
}

Both better-sqlite3 and bun:sqlite support transaction(), so this is simply an omission in the interface definition.

Verified

npm install && npm run build  # ✅ compiles successfully

The custom Database interface in db.ts was missing the transaction()
method, causing TypeScript compilation to fail on store.ts line 2142.
Both better-sqlite3 and bun:sqlite support transaction(), so this
was simply an omission in the interface definition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant