Skip to content

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

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);

Activity

  1. Renegade334 commented on Aug 23, 2025

    @Renegade334
    Member
  2. edilson258 commented on Aug 23, 2025

    @edilson258
    Author

    Okay, but i do not know if is the types wrong or is the implementation

  3. Renegade334 commented on Aug 23, 2025

    @Renegade334
    Member

    It's just not completely documented on the Node.js side, which hopefully #59598 addresses.

  4. added
    sqliteIssues and PRs related to the SQLite subsystem.
    on Aug 23, 2025
  5. geeksilva97 commented on Aug 28, 2025

    @geeksilva97
    Contributor

    PR has landed. Can this issue be closed, @Renegade334 ?

  6. Renegade334 commented on Aug 28, 2025

    @Renegade334
    Member

    The @types/node side of things doesn't affect this repo, so I'd say so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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