Skip to content

getInstances type is incorrect: returns a Promise when callback is unspecified #564

@lukasschwab

Description

@lukasschwab

Environment details

  • OS: macOS 10.14
  • Node.js version: v12.12.0
  • npm version: 6.11.3
  • @google-cloud/bigtable version: 2.2.1

Steps to reproduce

I have code that calls getInstances without defining a callback:

const [instances] = await bigtable.getInstances();

getInstances behaves according to its docstring:

If the callback is omitted, we'll return a Promise.

...but this behavior is not reflected in its generated type, which has return type void and no overloads:

getInstances(gaxOptions?: any, callback?: any): void;

This mismatch causes eslint to complain because void is a non-Promise.

Screen Shot 2019-11-07 at 15 44 55

Proposal

Declare an overload type:

getInstances(gaxOptions?: any, callback: any): void;
getInstances(gaxOptions?: any): Promise<Instance[]>;

Thanks!

Metadata

Metadata

Assignees

Labels

api: bigtableIssues related to the googleapis/nodejs-bigtable 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.typescript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions