Skip to content

Commit d751378

Browse files
committed
fix: type widening to match gapic, and two typing fixes
1 parent 7075430 commit d751378

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/publisher/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ export class Publisher {
191191
// We must have at least one of:
192192
// - `data` as a Buffer
193193
// - `attributes` that are not empty
194-
if (data && !(data instanceof Buffer)) {
195-
throw new TypeError('Data must be in the form of a Buffer.');
194+
if (data && !(data instanceof Uint8Array)) {
195+
throw new TypeError(
196+
'Data must be in the form of a Buffer or Uint8Array.'
197+
);
196198
}
197199

198200
const keys = Object.keys(attributes!);

test/publisher/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe('Publisher', () => {
237237
const badData = {} as Buffer;
238238
assert.throws(
239239
() => publisher.publishMessage({data: badData}, spy),
240-
/Data must be in the form of a Buffer\./
240+
/Data must be in the form of a Buffer or Uint8Array\./
241241
);
242242
});
243243

test/pubsub.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ describe('PubSub', () => {
689689
const apiResponse = {
690690
name: 'new-topic',
691691
};
692-
let requestStub: sinon.SinonStub<unknown[], unknown>;
692+
693+
// Types changed, so this is needed instead of `unknown`.
694+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
695+
let requestStub: sinon.SinonStub<any[], any>;
693696

694697
beforeEach(() => {
695698
requestStub = sandbox

0 commit comments

Comments
 (0)