Skip to content

Missing Promise functions on BatchTransaction #1899

Closed
@pequalsnp

Description

@pequalsnp

Environment details

  • OS: OSX
  • Node.js version: v18.16.0
  • npm version: 9.5.1
  • @google-cloud/spanner version: 6.12.0

Steps to reproduce

  1. Use Typescript
  2. Attempt to use batch transactions as shown in samples/batch.js
    const query = {
      sql: `
        select
          *
        from
          ${POST_TABLE_NAME}
      `,
    };

    const [transaction] = await this.database.createBatchTransaction();
    const partitions = transaction.createQueryPartitions(query);
  1. Get tsc error:
    domains/archive/post-service/src/post-service-spanner.repository.ts:274:11 - error TS2488: Type 'void' must have a '[Symbol.iterator]()' method that returns an iterator.

    274     const [partitions] = await transaction.createQueryPartitions(query);
                  ~~~~~~~~~~~~
    domains/archive/post-service/src/post-service-spanner.repository.ts:274:44 - error TS2554: Expected 2 arguments, but got 1.

    274     const [partitions] = await transaction.createQueryPartitions(query);
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      node_modules/@google-cloud/spanner/build/src/batch-transaction.d.ts:111:39
        111     createQueryPartitions(query: any, callback: any): void;
                                                  ~~~~~~~~~~~~~
        An argument for 'callback' was not provided.

The problem appears to be that your use of promisifyAll doesn't cause the appropriate method types to be included in the .d.ts file.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/nodejs-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions