Skip to content

Commit 47eba06

Browse files
committed
refactor(database): Add 'noImplicitAny' support
Adds support for the 'noImplicitAny' Typescript compiler option to the database implementation.
1 parent ae6b3c4 commit 47eba06

File tree

10 files changed

+19
-20
lines changed

10 files changed

+19
-20
lines changed

src/database/api/Query.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ export class Query {
222222
* @param context
223223
* @return {!firebase.Promise}
224224
*/
225-
once(eventType: string,
226-
userCallback?: SnapshotCallback,
227-
cancelOrContext?, context?: Object): Promise<DataSnapshot> {
225+
once(eventType: string, userCallback?: SnapshotCallback,
226+
cancelOrContext?: ((a: Error) => void) | Object, context?: Object): Promise<DataSnapshot> {
228227
validateArgCount('Query.once', 1, 4, arguments.length);
229228
validateEventType('Query.once', 1, eventType, false);
230229
validateCallback('Query.once', 2, userCallback, true);

src/database/core/SyncTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ export class SyncTree {
521521
let queries: Query[] = [];
522522
if (maybeChildSyncPoint) {
523523
queries = queries.concat(
524-
maybeChildSyncPoint.getQueryViews().map(view=> view.getQuery())
524+
maybeChildSyncPoint.getQueryViews().map(view=> view.getQuery())
525525
);
526526
}
527527
forEach(childMap, function (key: string, childQueries: Query[]) {

src/database/core/snap/ChildrenNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class ChildrenNode implements Node {
186186
// convert to array.
187187
const array: Object[] = [];
188188
for (let key in obj)
189-
array[key as any as number] = obj[key];
189+
array[<number><any>key as any as number] = obj[key];
190190

191191
return array;
192192
} else {

src/database/core/snap/childSet.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ export const buildChildSet = function<K,V>(childList: NamedNode[],
6464
return null;
6565
} else if (length == 1) {
6666
namedNode = childList[low];
67-
key = keyFn ? keyFn(namedNode) : namedNode as any as K;
68-
return new LLRBNode(key, namedNode.node as any as V, LLRBNode.BLACK, null, null);
67+
key = keyFn ? keyFn(namedNode) : <K><any>namedNode as any as K;
68+
return new LLRBNode(key, <V><any>namedNode.node as any as V, LLRBNode.BLACK, null, null);
6969
} else {
7070
const middle = parseInt((length / 2 as any), 10) + low;
7171
const left = buildBalancedTree(low, middle);
7272
const right = buildBalancedTree(middle + 1, high);
7373
namedNode = childList[middle];
74-
key = keyFn ? keyFn(namedNode) : namedNode as any as K;
75-
return new LLRBNode(key, namedNode.node as any as V, LLRBNode.BLACK, left, right);
74+
key = keyFn ? keyFn(namedNode) : <K><any>namedNode as any as K;
75+
return new LLRBNode(key, <V><any>namedNode.node as any as V, LLRBNode.BLACK, left, right);
7676
}
7777
};
7878

@@ -87,8 +87,8 @@ export const buildChildSet = function<K,V>(childList: NamedNode[],
8787
index -= chunkSize;
8888
const childTree = buildBalancedTree(low + 1, high);
8989
const namedNode = childList[low];
90-
const key: K = keyFn ? keyFn(namedNode) : namedNode as any as K;
91-
attachPennant(new LLRBNode(key, namedNode.node as any as V, color, null, childTree));
90+
const key: K = keyFn ? keyFn(namedNode) : <K><any>namedNode as any as K;
91+
attachPennant(new LLRBNode(key, <V><any>namedNode.node as any as V, color, null, childTree));
9292
};
9393

9494
const attachPennant = function (pennant: LLRBNode<K, V>) {

src/database/core/util/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ export const warnAboutUnsupportedMethod = function (methodName: string) {
240240
*/
241241
export const isInvalidJSONNumber = function (data: any): boolean {
242242
return typeof data === 'number' &&
243-
(data != data || // NaN
244-
data == Number.POSITIVE_INFINITY ||
245-
data == Number.NEGATIVE_INFINITY);
243+
(data != data || // NaN
244+
data == Number.POSITIVE_INFINITY ||
245+
data == Number.NEGATIVE_INFINITY);
246246
};
247247

248248

src/database/core/view/ChildChangeAccumulator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ChildChangeAccumulator {
1818
type == Change.CHILD_CHANGED ||
1919
type == Change.CHILD_REMOVED, 'Only child changes supported for tracking');
2020
assert(childKey !== '.priority', 'Only non-priority child changes can be tracked.');
21-
const oldChange = safeGet(this.changeMap_, childKey) as Change;
21+
const oldChange = <Change>safeGet(this.changeMap_, childKey) as Change;
2222
if (oldChange) {
2323
const oldType = oldChange.type;
2424
if (type == Change.CHILD_ADDED && oldType == Change.CHILD_REMOVED) {

src/database/realtime/Connection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class Connection {
199199

200200
private onSecondaryControl_(controlData: { [k: string]: any }) {
201201
if (MESSAGE_TYPE in controlData) {
202-
const cmd: string = controlData[MESSAGE_TYPE] as string;
202+
const cmd = <string>controlData[MESSAGE_TYPE] as string;
203203
if (cmd === SWITCH_ACK) {
204204
this.upgradeIfSecondaryHealthy_();
205205
} else if (cmd === CONTROL_RESET) {
@@ -292,7 +292,7 @@ export class Connection {
292292
private onControl_(controlData: { [k: string]: any }) {
293293
const cmd: string = requireKey(MESSAGE_TYPE, controlData);
294294
if (MESSAGE_DATA in controlData) {
295-
const payload: any = controlData[MESSAGE_DATA];
295+
const payload = controlData[MESSAGE_DATA];
296296
if (cmd === SERVER_HELLO) {
297297
this.onHandshake_(payload);
298298
} else if (cmd === END_TRANSMISSION) {

src/database/realtime/Transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export abstract class Transport {
5353

5454
abstract markConnectionHealthy(): void;
5555

56-
abstract markConnectionHealthy();
56+
abstract markConnectionHealthy(): void;
5757
}
5858

5959
export interface TransportConstructor {

src/database/realtime/TransportManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class TransportManager {
5151
if (isSkipPollConnection) {
5252
this.transports_ = [WebSocketConnection];
5353
} else {
54-
const transports = this.transports_ = [] as TransportConstructor[];
54+
const transports = this.transports_ = <TransportConstructor[]>[] as TransportConstructor[];
5555
each(TransportManager.ALL_TRANSPORTS, (i: number, transport: TransportConstructor) => {
5656
if (transport && transport['isAvailable']()) {
5757
transports.push(transport);

src/database/realtime/WebSocketConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class WebSocketConnection implements Transport {
273273
handleIncomingFrame(mess: { [k: string]: any }) {
274274
if (this.mySock === null)
275275
return; // Chrome apparently delivers incoming packets even after we .close() the connection sometimes.
276-
const data: string = mess['data'] as string;
276+
const data = <string>mess['data'] as string;
277277
this.bytesReceived += data.length;
278278
this.stats_.incrementCounter('bytes_received', data.length);
279279

0 commit comments

Comments
 (0)