Skip to content

Commit 7367b5f

Browse files
committed
Start updating files
1 parent 4b126b7 commit 7367b5f

File tree

14 files changed

+35
-39
lines changed

14 files changed

+35
-39
lines changed

config/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"declaration": true,
55
"importHelpers": true,
66
"strictNullChecks": true,
7+
"noImplicitAny": true,
78
"lib": [
89
"es2015",
910
"dom"

packages/functions/index.node.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
import firebase from '@firebase/app';
1818
import { FirebaseApp } from '@firebase/app-types';
19-
import { FirebaseServiceFactory } from '@firebase/app-types/private';
19+
import { FirebaseServiceFactory, _FirebaseNamespace } from '@firebase/app-types/private';
2020
import { Service } from './src/api/service';
2121
import 'isomorphic-fetch';
2222

@@ -29,7 +29,7 @@ function factory(app: FirebaseApp, unused: any, region?: string): Service {
2929
return new Service(app, region);
3030
}
3131

32-
export function registerFunctions(instance) {
32+
export function registerFunctions(instance: _FirebaseNamespace) {
3333
let namespaceExports = {
3434
// no-inline
3535
Functions: Service
@@ -45,4 +45,4 @@ export function registerFunctions(instance) {
4545
);
4646
}
4747

48-
registerFunctions(firebase);
48+
registerFunctions(firebase as _FirebaseNamespace);

packages/functions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
import firebase from '@firebase/app';
1818
import * as app_types from '@firebase/app-types';
19-
import { FirebaseServiceFactory } from '@firebase/app-types/private';
19+
import { FirebaseServiceFactory, _FirebaseNamespace } from '@firebase/app-types/private';
2020
import * as types from '@firebase/functions-types';
2121
import { Service } from './src/api/service';
2222

@@ -33,7 +33,7 @@ function factory(
3333
return new Service(app, region);
3434
}
3535

36-
export function registerFunctions(instance) {
36+
export function registerFunctions(instance: _FirebaseNamespace) {
3737
let namespaceExports = {
3838
// no-inline
3939
Functions: Service
@@ -49,7 +49,7 @@ export function registerFunctions(instance) {
4949
);
5050
}
5151

52-
registerFunctions(firebase);
52+
registerFunctions(firebase as _FirebaseNamespace);
5353

5454
declare module '@firebase/app-types' {
5555
interface FirebaseNamespace {

packages/functions/src/serializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
const LONG_TYPE = 'type.googleapis.com/google.protobuf.Int64Value';
1919
const UNSIGNED_LONG_TYPE = 'type.googleapis.com/google.protobuf.UInt64Value';
2020

21-
function mapValues(o: object, f: (any) => any): object {
22-
let result = {};
21+
function mapValues(o: { [key: string]: any }, f: (arg0: any) => any): object {
22+
let result: { [key: string]: any } = {};
2323
for (var key in o) {
2424
if (o.hasOwnProperty(key)) {
2525
result[key] = f(o[key]);

packages/logger/src/logger.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ export class Logger {
139139
* The functions below are all based on the `console` interface
140140
*/
141141

142-
debug(...args) {
142+
debug(...args: any[]) {
143143
this._logHandler(this, LogLevel.DEBUG, ...args);
144144
}
145-
log(...args) {
145+
log(...args: any[]) {
146146
this._logHandler(this, LogLevel.VERBOSE, ...args);
147147
}
148-
info(...args) {
148+
info(...args: any[]) {
149149
this._logHandler(this, LogLevel.INFO, ...args);
150150
}
151-
warn(...args) {
151+
warn(...args: any[]) {
152152
this._logHandler(this, LogLevel.WARN, ...args);
153153
}
154-
error(...args) {
154+
error(...args: any[]) {
155155
this._logHandler(this, LogLevel.ERROR, ...args);
156156
}
157157
}

packages/storage/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import firebase from '@firebase/app';
1919
import { FirebaseApp } from '@firebase/app-types';
20-
import { FirebaseServiceFactory } from '@firebase/app-types/private';
20+
import { FirebaseServiceFactory, _FirebaseNamespace } from '@firebase/app-types/private';
2121
import { StringFormat } from './src/implementation/string';
2222
import { TaskEvent } from './src/implementation/taskenums';
2323
import { TaskState } from './src/implementation/taskenums';
@@ -39,7 +39,7 @@ function factory(
3939
return new Service(app, new XhrIoPool(), opt_url) as any;
4040
}
4141

42-
export function registerStorage(instance) {
42+
export function registerStorage(instance: _FirebaseNamespace) {
4343
let namespaceExports = {
4444
// no-inline
4545
TaskState: TaskState,
@@ -58,7 +58,7 @@ export function registerStorage(instance) {
5858
);
5959
}
6060

61-
registerStorage(firebase);
61+
registerStorage(firebase as _FirebaseNamespace);
6262

6363
/**
6464
* Define extension behavior for `registerStorage`

packages/storage/src/implementation/fs.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
*/
2222
import * as type from './type';
2323

24-
declare var IBlobBuilder;
25-
declare var BlobBuilder;
26-
declare var WebKitBlobBuilder;
27-
2824
function getBlobBuilder(): (typeof IBlobBuilder) | undefined {
2925
if (typeof BlobBuilder !== 'undefined') {
3026
return BlobBuilder;

packages/storage/src/implementation/requests.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function list(
163163
pageToken?: string | null,
164164
maxResults?: number | null
165165
): RequestInfo<ListResult> {
166-
let urlParams = {};
166+
let urlParams: { [key: string]: any } = {};
167167
if (location.isRoot) {
168168
urlParams['prefix'] = '';
169169
} else {
@@ -427,13 +427,16 @@ export function getResumableUploadStatus(
427427

428428
function handler(xhr: XhrIo, text: string): ResumableUploadStatus {
429429
let status = checkResumeHeader_(xhr, ['active', 'final']);
430-
let sizeString;
430+
let sizeString: string | null = null;
431431
try {
432432
sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');
433+
if (sizeString === null) {
434+
handlerCheck(false);
435+
}
433436
} catch (e) {
434437
handlerCheck(false);
435438
}
436-
let size = parseInt(sizeString, 10);
439+
let size = parseInt(sizeString as string, 10);
437440
handlerCheck(!isNaN(size));
438441
return new ResumableUploadStatus(size, blob.size(), status === 'final');
439442
}

packages/util/src/assert.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,17 @@ import { CONSTANTS } from './constants';
1919

2020
/**
2121
* Throws an error if the provided assertion is falsy
22-
* @param {*} assertion The assertion to be tested for falsiness
23-
* @param {!string} message The message to display if the check fails
2422
*/
25-
export const assert = function(assertion, message) {
23+
export const assert = function(assertion: any, message: string) {
2624
if (!assertion) {
2725
throw assertionError(message);
2826
}
2927
};
3028

3129
/**
3230
* Returns an Error object suitable for throwing.
33-
* @param {string} message
34-
* @return {!Error}
3531
*/
36-
export const assertionError = function(message) {
32+
export const assertionError = function(message: string): Error {
3733
return new Error(
3834
'Firebase Database (' +
3935
CONSTANTS.SDK_VERSION +

packages/util/src/crypt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
const stringToByteArray = function(str) {
18+
const stringToByteArray = function(str: string) {
1919
// TODO(user): Use native implementations if/when available
2020
var out: number[] = [],
2121
p = 0;
@@ -52,7 +52,7 @@ const stringToByteArray = function(str) {
5252
* @param bytes Array of numbers representing characters.
5353
* @return Stringification of the array.
5454
*/
55-
const byteArrayToString = function(bytes) {
55+
const byteArrayToString = function(bytes: number[]) {
5656
// TODO(user): Use native implementations if/when available
5757
var out: string[] = [],
5858
pos = 0,

packages/util/src/deferred.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
export class Deferred<R> {
1919
promise: Promise<R>;
20-
reject;
21-
resolve;
20+
reject: (value?: R | PromiseLike<R> | Error ) => void;
21+
resolve: (value?: R | PromiseLike<R>) => void;
2222
constructor() {
2323
this.promise = new Promise((resolve, reject) => {
2424
this.resolve = resolve;
@@ -30,10 +30,8 @@ export class Deferred<R> {
3030
* Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
3131
* invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
3232
* and returns a node-style callback which will resolve or reject the Deferred's promise.
33-
* @param {((?function(?(Error)): (?|undefined))| (?function(?(Error),?=): (?|undefined)))=} callback
34-
* @return {!function(?(Error), ?=)}
3533
*/
36-
wrapCallback(callback?) {
34+
wrapCallback(callback?: (error?: Error, value?: any) => void): (error: Error, value?: any) => void {
3735
return (error, value?) => {
3836
if (error) {
3937
this.reject(error);

packages/util/src/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export function getUA(): string {
4242
export function isMobileCordova(): boolean {
4343
return (
4444
typeof window !== 'undefined' &&
45+
// @ts-ignore Setting up an broadly applicable index signature for Window
46+
// just to deal with this case would probably be a bad idea.
4547
!!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
4648
/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())
4749
);

packages/util/src/json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @param {string} str A string containing JSON.
2222
* @return {*} The javascript object representing the specified JSON.
2323
*/
24-
export function jsonEval(str) {
24+
export function jsonEval(str: string): { [key: string]: any } {
2525
return JSON.parse(str);
2626
}
2727

@@ -30,6 +30,6 @@ export function jsonEval(str) {
3030
* @param {*} data Javascript object to be stringified.
3131
* @return {string} The JSON contents of the object.
3232
*/
33-
export function stringify(data) {
33+
export function stringify(data: any): string {
3434
return JSON.stringify(data);
3535
}

packages/util/src/jwt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { jsonEval } from './json';
2828
* @param {?string} token
2929
* @return {{header: *, claims: *, data: *, signature: string}}
3030
*/
31-
export const decode = function(token) {
31+
export const decode = function(token: string): {} {
3232
var header = {},
3333
claims = {},
3434
data = {},

0 commit comments

Comments
 (0)