Skip to content

Commit

Permalink
Enable strictBindCallApply.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Lehenbauer committed Aug 9, 2019
1 parent 31dac0d commit b0f6e83
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
10 changes: 9 additions & 1 deletion packages/firestore/src/local/persistence_promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,18 @@ export class PersistencePromise<T> {
* to resolve.
*/
static forEach<R, S>(
collection: { forEach: (cb: (r: R, s?: S) => void) => void },
collection: { forEach: (cb: (r: R, s: S) => void) => void },
f:
| ((r: R, s: S) => PersistencePromise<void>)
| ((r: R) => PersistencePromise<void>)
): PersistencePromise<void>;
static forEach<R>(
collection: { forEach: (cb: (r: R) => void) => void },
f: (r: R) => PersistencePromise<void>
): PersistencePromise<void>;
static forEach<R, S>(
collection: { forEach: (cb: (r: R, s?: S) => void) => void },
f: (r: R, s?: S) => PersistencePromise<void>
): PersistencePromise<void> {
const promises: Array<PersistencePromise<void>> = [];
collection.forEach((r, s) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/firestore/src/util/async_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ export class AsyncQueue {
`Attempted to schedule multiple operations with timer id ${timerId}.`
);

const delayedOp = DelayedOperation.createAndSchedule<unknown>(
const delayedOp = DelayedOperation.createAndSchedule<T>(
this,
timerId,
delayMs,
op,
op => this.removeDelayedOperation(op)
op => this.removeDelayedOperation(op as DelayedOperation<unknown>)
);
this.delayedOperations.push(delayedOp);
this.delayedOperations.push(delayedOp as DelayedOperation<unknown>);

return delayedOp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describeFn('WebChannel', () => {
const makeUrl = conn.makeUrl.bind(conn);

it('includes project ID and database ID', () => {
const url = makeUrl('Commit', {});
const url = makeUrl('Commit');
expect(url).to.equal(
'http://example.com/v1/projects/testproject/' +
'databases/(default)/documents:commit'
Expand Down
25 changes: 19 additions & 6 deletions packages/firestore/test/integration/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,11 @@ export function isRunningAgainstEmulator(): boolean {
}

/**
* A wrapper around Jasmine's describe method that allows for it to be run with
* A wrapper around Mocha's describe method that allows for it to be run with
* persistence both disabled and enabled (if the browser is supported).
*/
export const apiDescribe = apiDescribeInternal.bind(null, describe);
apiDescribe.skip = apiDescribeInternal.bind(null, describe.skip);
apiDescribe.only = apiDescribeInternal.bind(null, describe.only);

function apiDescribeInternal(
describeFn: Mocha.IContextDefinition,
describeFn: Mocha.PendingSuiteFunction,
message: string,
testSuite: (persistence: boolean) => void
): void {
Expand All @@ -111,6 +107,23 @@ function apiDescribeInternal(
}
}

type ApiSuiteFunction = (
message: string,
testSuite: (persistence: boolean) => void
) => void;
interface ApiDescribe {
(message: string, testSuite: (persistence: boolean) => void): void;
skip: ApiSuiteFunction;
only: ApiSuiteFunction;
}

export const apiDescribe = apiDescribeInternal.bind(
null,
describe
) as ApiDescribe;
apiDescribe.skip = apiDescribeInternal.bind(null, describe.skip);
apiDescribe.only = apiDescribeInternal.bind(null, describe.only);

/** Converts the documents in a QuerySnapshot to an array with the data of each document. */
export function toDataArray(
docSet: firestore.QuerySnapshot
Expand Down
5 changes: 2 additions & 3 deletions packages/firestore/test/util/equality_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ export function addEqualityMatcher(): void {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const assertEql = (_super: (r: unknown, l: unknown) => boolean) => {
originalFunction = originalFunction || _super;
return function(this: {}, ...args: unknown[]): void {
return function(this: {}, expected?: unknown, msg?: unknown): void {
if (isActive) {
const [expected, msg] = args;
utils.flag(this, 'message', msg);
const actual = utils.flag(this, 'object');

Expand All @@ -106,7 +105,7 @@ export function addEqualityMatcher(): void {
/*showDiff=*/ true
);
} else if (originalFunction) {
originalFunction.apply(this, args);
originalFunction.call(this, expected, msg);
}
};
};
Expand Down
1 change: 0 additions & 1 deletion packages/firestore/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"strictBindCallApply": false,
"strictPropertyInitialization": false
},
"exclude": [
Expand Down

0 comments on commit b0f6e83

Please sign in to comment.