Skip to content

Commit

Permalink
fix: improve typescript types for Table class (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Mar 17, 2020
1 parent 87c2c6b commit 68179d1
Show file tree
Hide file tree
Showing 5 changed files with 517 additions and 195 deletions.
7 changes: 3 additions & 4 deletions src/family.ts
Expand Up @@ -17,7 +17,6 @@
import {promisifyAll} from '@google-cloud/promisify';
import {CallOptions} from 'google-gax';
import {ServiceError} from '@grpc/grpc-js';
import * as is from 'is';

import {Bigtable} from './';
import {Table} from './table';
Expand Down Expand Up @@ -392,9 +391,9 @@ Please use the format 'follows' or '${table.name}/columnFamilies/my-family'.`);
return;
}

for (let i = 0, l = families.length; i < l; i++) {
if (families[i].name === this.name) {
this.metadata = families[i].metadata;
for (let i = 0, l = families!.length; i < l; i++) {
if (families![i].name === this.name) {
this.metadata = families![i].metadata;
callback(null, this.metadata);
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/index.ts
Expand Up @@ -712,7 +712,10 @@ export class Bigtable {
* @param {object} config.reqOpts Request options.
* @param {function} [callback] Callback function.
*/
request(config, callback) {
request<T = any>(
config?: any,
callback?: (err: ServiceError | null, resp?: T) => void
) {
const isStreamMode = !callback;

let gaxStream;
Expand Down Expand Up @@ -768,7 +771,7 @@ export class Bigtable {
function makeRequestCallback() {
prepareGaxRequest((err, requestFn) => {
if (err) {
callback(err);
callback!(err);
return;
}

Expand Down

0 comments on commit 68179d1

Please sign in to comment.