Skip to content

Commit 3f9e8e8

Browse files
author
Michael Lehenbauer
authored
Enable strictBindCallApply for Firestore. (#2074)
1 parent 140d352 commit 3f9e8e8

File tree

6 files changed

+35
-15
lines changed

6 files changed

+35
-15
lines changed

packages/firestore/src/local/persistence_promise.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,18 @@ export class PersistencePromise<T> {
224224
* to resolve.
225225
*/
226226
static forEach<R, S>(
227-
collection: { forEach: (cb: (r: R, s?: S) => void) => void },
227+
collection: { forEach: (cb: (r: R, s: S) => void) => void },
228228
f:
229229
| ((r: R, s: S) => PersistencePromise<void>)
230230
| ((r: R) => PersistencePromise<void>)
231+
): PersistencePromise<void>;
232+
static forEach<R>(
233+
collection: { forEach: (cb: (r: R) => void) => void },
234+
f: (r: R) => PersistencePromise<void>
235+
): PersistencePromise<void>;
236+
static forEach<R, S>(
237+
collection: { forEach: (cb: (r: R, s?: S) => void) => void },
238+
f: (r: R, s?: S) => PersistencePromise<void>
231239
): PersistencePromise<void> {
232240
const promises: Array<PersistencePromise<void>> = [];
233241
collection.forEach((r, s) => {

packages/firestore/src/util/async_queue.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,15 @@ export class AsyncQueue {
326326
`Attempted to schedule multiple operations with timer id ${timerId}.`
327327
);
328328

329-
const delayedOp = DelayedOperation.createAndSchedule<unknown>(
329+
const delayedOp = DelayedOperation.createAndSchedule<T>(
330330
this,
331331
timerId,
332332
delayMs,
333333
op,
334-
op => this.removeDelayedOperation(op)
334+
removedOp =>
335+
this.removeDelayedOperation(removedOp as DelayedOperation<unknown>)
335336
);
336-
this.delayedOperations.push(delayedOp);
337+
this.delayedOperations.push(delayedOp as DelayedOperation<unknown>);
337338

338339
return delayedOp;
339340
}

packages/firestore/test/integration/browser/webchannel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describeFn('WebChannel', () => {
4242
const makeUrl = conn.makeUrl.bind(conn);
4343

4444
it('includes project ID and database ID', () => {
45-
const url = makeUrl('Commit', {});
45+
const url = makeUrl('Commit');
4646
expect(url).to.equal(
4747
'http://example.com/v1/projects/testproject/' +
4848
'databases/(default)/documents:commit'

packages/firestore/test/integration/util/helpers.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,11 @@ export function isRunningAgainstEmulator(): boolean {
8989
}
9090

9191
/**
92-
* A wrapper around Jasmine's describe method that allows for it to be run with
92+
* A wrapper around Mocha's describe method that allows for it to be run with
9393
* persistence both disabled and enabled (if the browser is supported).
9494
*/
95-
export const apiDescribe = apiDescribeInternal.bind(null, describe);
96-
apiDescribe.skip = apiDescribeInternal.bind(null, describe.skip);
97-
apiDescribe.only = apiDescribeInternal.bind(null, describe.only);
98-
9995
function apiDescribeInternal(
100-
describeFn: Mocha.IContextDefinition,
96+
describeFn: Mocha.PendingSuiteFunction,
10197
message: string,
10298
testSuite: (persistence: boolean) => void
10399
): void {
@@ -111,6 +107,23 @@ function apiDescribeInternal(
111107
}
112108
}
113109

110+
type ApiSuiteFunction = (
111+
message: string,
112+
testSuite: (persistence: boolean) => void
113+
) => void;
114+
interface ApiDescribe {
115+
(message: string, testSuite: (persistence: boolean) => void): void;
116+
skip: ApiSuiteFunction;
117+
only: ApiSuiteFunction;
118+
}
119+
120+
export const apiDescribe = apiDescribeInternal.bind(
121+
null,
122+
describe
123+
) as ApiDescribe;
124+
apiDescribe.skip = apiDescribeInternal.bind(null, describe.skip);
125+
apiDescribe.only = apiDescribeInternal.bind(null, describe.only);
126+
114127
/** Converts the documents in a QuerySnapshot to an array with the data of each document. */
115128
export function toDataArray(
116129
docSet: firestore.QuerySnapshot

packages/firestore/test/util/equality_matcher.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ export function addEqualityMatcher(): void {
8787
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
8888
const assertEql = (_super: (r: unknown, l: unknown) => boolean) => {
8989
originalFunction = originalFunction || _super;
90-
return function(this: unknown, ...args: unknown[]): void {
90+
return function(this: unknown, expected?: unknown, msg?: unknown): void {
9191
if (isActive) {
92-
const [expected, msg] = args;
9392
utils.flag(this, 'message', msg);
9493
const actual = utils.flag(this, 'object');
9594

@@ -106,7 +105,7 @@ export function addEqualityMatcher(): void {
106105
/*showDiff=*/ true
107106
);
108107
} else if (originalFunction) {
109-
originalFunction.apply(this, args);
108+
originalFunction.call(this, expected, msg);
110109
}
111110
};
112111
};

packages/firestore/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../../config/tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "dist",
5-
"strictBindCallApply": false,
65
"strictPropertyInitialization": false
76
},
87
"exclude": [

0 commit comments

Comments
 (0)