Skip to content

sqlite.backup() TypeScript definition incorrectly returns Promise<void> instead of Promise<number> #59597

@edilson258

Description

@edilson258

The backup() function in Node.js SQLite bindings currently has its TypeScript type defined as returning Promise<void>. However, the actual implementation returns an Promise<number> representing the number of pages backed up.

  1. Definition from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d65f24c95e732e4b0eadaebf63f5699801a05e59/types/node/v22/sqlite.d.ts#L639

  1. Example from nodejs docs https://nodejs.org/api/sqlite.html#sqlitebackupsourcedb-path-options
import { backup, DatabaseSync } from 'node:sqlite';

const sourceDb = new DatabaseSync('source.db');
const totalPagesTransferred = await backup(sourceDb, 'backup.db', {
  rate: 1, // Copy one page at a time.
  progress: ({ totalPages, remainingPages }) => {
    console.log('Backup in progress', { totalPages, remainingPages });
  },
});

console.log('Backup completed', totalPagesTransferred);

Metadata

Metadata

Assignees

No one assigned

    Labels

    sqliteIssues and PRs related to the SQLite subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions