Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 90034ce

Browse files
fix: new typescript, strict types (#824)
1 parent 408f113 commit 90034ce

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

test/unit/grpc.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('grpc', () => {
7272
'X-Goog-Api-Client': 'gl-node/6.6.0 gccl/0.7.0 gax/0.11.0 grpc/1.1.0',
7373
};
7474
const builder = grpcClient.metadataBuilder(headers);
75-
const abTesting = null;
75+
const abTesting: {} | null = null;
7676
const moreHeaders = {foo: 'bar'};
7777
const metadata = builder(abTesting!, moreHeaders);
7878
assert.deepStrictEqual(metadata.get('foo'), ['bar']);
@@ -85,7 +85,7 @@ describe('grpc', () => {
8585
'X-Goog-Api-Client': 'gl-node/6.6.0 gccl/0.7.0 gax/0.11.0 grpc/1.1.0',
8686
};
8787
const builder = grpcClient.metadataBuilder(headers);
88-
const abTesting = null;
88+
const abTesting: {} | null = null;
8989
const moreHeaders = {'x-GOOG-api-CLIENT': 'something else'};
9090
const metadata = builder(abTesting!, moreHeaders);
9191
assert.deepStrictEqual(metadata.get('x-goog-api-client'), [
@@ -117,7 +117,11 @@ describe('grpc', () => {
117117

118118
describe('createStub', () => {
119119
class DummyStub {
120-
constructor(public address: {}, public creds: {}, public options: {}) {}
120+
constructor(
121+
public address: {},
122+
public creds: {},
123+
public options: {[index: string]: string | number | Function}
124+
) {}
121125
}
122126
let grpcClient: GrpcClient;
123127
const dummyChannelCreds = {channelCreds: 'dummyChannelCreds'};
@@ -195,11 +199,15 @@ describe('grpc', () => {
195199
assert(stub.options.hasOwnProperty(k));
196200
});
197201
// check values
202+
const dummyStub = (stub as unknown) as DummyStub;
198203
assert.strictEqual(
199-
stub.options['grpc.max_send_message_length'],
204+
dummyStub.options['grpc.max_send_message_length'],
200205
10 * 1024 * 1024
201206
);
202-
assert.strictEqual(stub.options['callInvocationTransformer'](), 42);
207+
assert.strictEqual(
208+
(dummyStub.options['callInvocationTransformer'] as Function)(),
209+
42
210+
);
203211
['servicePath', 'port', 'other_dummy_options'].forEach(k => {
204212
assert.strictEqual(stub.options.hasOwnProperty(k), false);
205213
});
@@ -241,8 +249,9 @@ describe('grpc', () => {
241249
['servicePath', 'port'].forEach(k => {
242250
assert.strictEqual(stub.options.hasOwnProperty(k), false);
243251
});
252+
const dummyStub = (stub as unknown) as DummyStub;
244253
assert.strictEqual(
245-
stub.options['grpc.max_receive_message_length'],
254+
dummyStub.options['grpc.max_receive_message_length'],
246255
10 * 1024 * 1024
247256
);
248257
});

test/unit/pagedIteration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ describe('paged iteration', () => {
111111
.then(response => {
112112
assert.ok(Array.isArray(response));
113113
assert(Array.isArray(response[0]));
114-
assert.strictEqual(response[0].length, pageSize);
114+
assert.strictEqual((response[0] as Array<{}>).length, pageSize);
115115
for (let i = 0; i < pageSize; ++i) {
116-
assert.strictEqual(response[0][i], expected);
116+
assert.strictEqual((response[0] as Array<{}>)[i], expected);
117117
expected++;
118118
}
119119
done();

0 commit comments

Comments
 (0)