Skip to content

Commit

Permalink
fix(typescript): correct response type of Subscription.get
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinnot committed Mar 6, 2019
1 parent 0a03d63 commit 9952c00
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ export class PubSub {
topic: Topic|string, name: string,
options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
createSubscription(
topic: Topic|string, name: string, options: CreateSubscriptionOptions,
topic: Topic|string, name: string,
callback: CreateSubscriptionCallback): void;
createSubscription(
topic: Topic|string, name: string,
topic: Topic|string, name: string, options: CreateSubscriptionOptions,
callback: CreateSubscriptionCallback): void;
/**
* @typedef {array} CreateSubscriptionResponse
Expand Down Expand Up @@ -386,10 +386,11 @@ export class PubSub {
});
}

createTopic(name: string, gaxOpts: CallOptions): Promise<CreateTopicResponse>;
createTopic(
name: string, gaxOpts: CallOptions, callback?: CreateTopicCallback): void;
createTopic(name: string, gaxOpts?: CallOptions):
Promise<CreateTopicResponse>;
createTopic(name: string, callback: CreateTopicCallback): void;
createTopic(
name: string, gaxOpts: CallOptions, callback: CreateTopicCallback): void;
/**
* @typedef {array} CreateTopicResponse
* @property {Topic} 0 The new {@link Topic}.
Expand Down Expand Up @@ -484,9 +485,9 @@ export class PubSub {
this.isEmulator = true;
}

getSnapshots(option?: PageOptions): Promise<GetSnapshotsResponse>;
getSnapshots(options?: PageOptions): Promise<GetSnapshotsResponse>;
getSnapshots(callback: GetSnapshotsCallback): void;
getSnapshots(option: PageOptions, callback: GetSnapshotsCallback): void;
getSnapshots(options: PageOptions, callback: GetSnapshotsCallback): void;
/**
* Query object for listing snapshots.
*
Expand Down
8 changes: 4 additions & 4 deletions src/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type CreateSubscriptionResponse = SubscriptionResponse;

export type GetSubscriptionOptions = CallOptions&{autoCreate?: boolean};
export type GetSubscriptionCallback = SubscriptionCallback;
export type GetSubscriptionResponse = SubscriptionCallback;
export type GetSubscriptionResponse = SubscriptionResponse;

type MetadataCallback = RequestCallback<google.pubsub.v1.ISubscription>;
type MetadataResponse = [google.pubsub.v1.ISubscription];
Expand Down Expand Up @@ -355,9 +355,9 @@ export class Subscription extends EventEmitter {
});
}

createSnapshot(name: string, callback: CreateSnapshotCallback): void;
createSnapshot(name: string, gaxOpts?: CallOptions):
Promise<CreateSnapshotResponse>;
createSnapshot(name: string, callback: CreateSnapshotCallback): void;
createSnapshot(
name: string, gaxOpts: CallOptions,
callback: CreateSnapshotCallback): void;
Expand Down Expand Up @@ -437,8 +437,8 @@ export class Subscription extends EventEmitter {
});
}

delete(callback: EmptyCallback): void;
delete(gaxOpts?: CallOptions): Promise<EmptyResponse>;
delete(callback: EmptyCallback): void;
delete(gaxOpts: CallOptions, callback: EmptyCallback): void;
/**
* Delete the subscription. Pull requests from the current subscription will
Expand Down Expand Up @@ -545,8 +545,8 @@ export class Subscription extends EventEmitter {
});
}

get(callback: GetSubscriptionCallback): void;
get(gaxOpts?: GetSubscriptionOptions): Promise<GetSubscriptionResponse>;
get(callback: GetSubscriptionCallback): void;
get(gaxOpts: GetSubscriptionOptions, callback: GetSubscriptionCallback): void;
/**
* @typedef {array} GetSubscriptionResponse
Expand Down
2 changes: 1 addition & 1 deletion src/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class Topic {
callback =
typeof gaxOptsOrCallback === 'function' ? gaxOptsOrCallback : callback;

this.pubsub.createTopic(this.name, gaxOpts, callback);
this.pubsub.createTopic(this.name, gaxOpts, callback!);
}

createSubscription(name: string, callback: CreateSubscriptionCallback): void;
Expand Down

0 comments on commit 9952c00

Please sign in to comment.