Skip to content

Commit 977222a

Browse files
authored
Setting noImplicitAny: true (#353)
* Setting noImplicitAny: true * TS fixes in integration tests * Disabling noImplicitAny again due to RTDB typing issue * Added RTDB typings explicitly * Added trace resolution * Upgraded RTDB packages
1 parent e5e502f commit 977222a

29 files changed

+303
-572
lines changed

package-lock.json

Lines changed: 165 additions & 433 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
],
5353
"types": "./lib/index.d.ts",
5454
"dependencies": {
55-
"@firebase/app": "^0.3.1",
56-
"@firebase/database": "^0.3.1",
55+
"@firebase/app": "^0.3.4",
56+
"@firebase/database": "^0.3.6",
5757
"@types/node": "^8.0.53",
5858
"jsonwebtoken": "8.1.0",
5959
"node-forge": "0.7.4"
@@ -64,14 +64,18 @@
6464
"@types/google-cloud__storage": "^1.7.1"
6565
},
6666
"devDependencies": {
67+
"@types/bcrypt": "^2.0.0",
6768
"@types/chai": "^3.4.34",
6869
"@types/chai-as-promised": "0.0.29",
6970
"@types/firebase-token-generator": "^2.0.28",
71+
"@types/jsonwebtoken": "^7.2.8",
7072
"@types/lodash": "^4.14.104",
73+
"@types/minimist": "^1.2.0",
7174
"@types/mocha": "^2.2.48",
7275
"@types/nock": "^9.1.0",
7376
"@types/request": "^2.47.0",
7477
"@types/request-promise": "^4.1.41",
78+
"@types/scrypt": "^6.0.0",
7579
"@types/sinon": "^4.1.3",
7680
"@types/sinon-chai": "^2.7.27",
7781
"bcrypt": "^3.0.0",
@@ -84,9 +88,7 @@
8488
"gulp": "^3.9.1",
8589
"gulp-exit": "0.0.2",
8690
"gulp-header": "^1.8.8",
87-
"gulp-istanbul": "^1.1.3",
8891
"gulp-replace": "^0.5.4",
89-
"gulp-tslint": "^6.0.2",
9092
"gulp-typescript": "^3.2.4",
9193
"lodash": "^4.17.5",
9294
"merge2": "^1.2.1",

src/auth/auth-api-request.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function validateCreateEditRequest(request: any, uploadAccountRequest: boolean =
238238
// customAttributes should be stringified JSON with no blacklisted claims.
239239
// The payload should not exceed 1KB.
240240
if (typeof request.customAttributes !== 'undefined') {
241-
let developerClaims;
241+
let developerClaims: object;
242242
try {
243243
developerClaims = JSON.parse(request.customAttributes);
244244
} catch (error) {
@@ -247,7 +247,7 @@ function validateCreateEditRequest(request: any, uploadAccountRequest: boolean =
247247
// this field.
248248
throw new FirebaseAuthError(AuthClientErrorCode.INVALID_CLAIMS, error.message);
249249
}
250-
const invalidClaims = [];
250+
const invalidClaims: string[] = [];
251251
// Check for any invalid claims.
252252
RESERVED_CLAIMS.forEach((blacklistedClaim) => {
253253
if (developerClaims.hasOwnProperty(blacklistedClaim)) {
@@ -286,7 +286,7 @@ function validateCreateEditRequest(request: any, uploadAccountRequest: boolean =
286286
!validator.isArray(request.providerUserInfo)) {
287287
throw new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_DATA);
288288
} else if (validator.isArray(request.providerUserInfo)) {
289-
request.providerUserInfo.forEach((providerUserInfoEntry) => {
289+
request.providerUserInfo.forEach((providerUserInfoEntry: any) => {
290290
validateProviderUserInfo(providerUserInfoEntry);
291291
});
292292
}
@@ -681,7 +681,7 @@ export class FirebaseAuthRequestHandler {
681681

682682
// Parameters that are deletable and their deleteAttribute names.
683683
// Use client facing names, photoURL instead of photoUrl.
684-
const deletableParams = {
684+
const deletableParams: {[key: string]: string} = {
685685
displayName: 'DISPLAY_NAME',
686686
photoURL: 'PHOTO_URL',
687687
};

src/auth/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class Auth implements FirebaseServiceInterface {
220220
// List of users to return.
221221
const users: UserRecord[] = [];
222222
// Convert each user response to a UserRecord.
223-
response.users.forEach((userResponse) => {
223+
response.users.forEach((userResponse: any) => {
224224
users.push(new UserRecord(userResponse));
225225
});
226226
// Return list of user records and the next page token if available.

src/auth/credential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ONE_HOUR_IN_SECONDS = 60 * 60;
5252
const JWT_ALGORITHM = 'RS256';
5353

5454

55-
function copyAttr(to: object, from: object, key: string, alt: string) {
55+
function copyAttr(to: {[key: string]: any}, from: {[key: string]: any}, key: string, alt: string) {
5656
const tmp = from[key] || from[alt];
5757
if (typeof tmp !== 'undefined') {
5858
to[key] = tmp;

src/auth/token-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export class FirebaseTokenGenerator {
253253
* @return {Promise<string>} A Promise fulfilled with a Firebase Auth Custom token signed with a
254254
* service account key and containing the provided payload.
255255
*/
256-
public createCustomToken(uid: string, developerClaims?: object): Promise<string> {
256+
public createCustomToken(uid: string, developerClaims?: {[key: string]: any}): Promise<string> {
257257
let errorMessage: string;
258258
if (typeof uid !== 'string' || uid === '') {
259259
errorMessage = 'First argument to createCustomToken() must be a non-empty string uid.';
@@ -267,7 +267,7 @@ export class FirebaseTokenGenerator {
267267
throw new FirebaseAuthError(AuthClientErrorCode.INVALID_ARGUMENT, errorMessage);
268268
}
269269

270-
const claims = {};
270+
const claims: {[key: string]: any} = {};
271271
if (typeof developerClaims !== 'undefined') {
272272
for (const key in developerClaims) {
273273
/* istanbul ignore else */

src/auth/token-verifier.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface FirebaseTokenInfo {
6868
* Class for verifying general purpose Firebase JWTs. This verifies ID tokens and session cookies.
6969
*/
7070
export class FirebaseTokenVerifier {
71-
private publicKeys: object;
71+
private publicKeys: {[key: string]: string};
7272
private publicKeysExpireAt: number;
7373
private readonly shortNameArticle: string;
7474

@@ -234,7 +234,7 @@ export class FirebaseTokenVerifier {
234234
return new Promise((resolve, reject) => {
235235
jwt.verify(jwtToken, publicKey, {
236236
algorithms: [this.algorithm],
237-
}, (error, decodedToken: any) => {
237+
}, (error: any, decodedToken: any) => {
238238
if (error) {
239239
if (error.name === 'TokenExpiredError') {
240240
errorMessage = `${this.tokenInfo.jwtName} has expired. Get a fresh token from your client ` +
@@ -257,7 +257,7 @@ export class FirebaseTokenVerifier {
257257
*
258258
* @return {Promise<object>} A promise fulfilled with public keys for the Google certs.
259259
*/
260-
private fetchPublicKeys(): Promise<object> {
260+
private fetchPublicKeys(): Promise<{[key: string]: string}> {
261261
const publicKeysExist = (typeof this.publicKeys !== 'undefined');
262262
const publicKeysExpiredExists = (typeof this.publicKeysExpireAt !== 'undefined');
263263
const publicKeysStillValid = (publicKeysExpiredExists && Date.now() < this.publicKeysExpireAt);

src/auth/user-import-builder.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export interface UserImportResult {
119119

120120

121121
/** Callback function to validate an UploadAccountUser object. */
122-
type ValidatorFunction = (data: UploadAccountUser) => void;
122+
export type ValidatorFunction = (data: UploadAccountUser) => void;
123123

124124

125125
/**
@@ -191,7 +191,8 @@ function populateUploadAccountUser(
191191
});
192192
}
193193
// Remove blank fields.
194-
for (const key in result) {
194+
let key: keyof UploadAccountUser;
195+
for (key in result) {
195196
if (typeof result[key] === 'undefined') {
196197
delete result[key];
197198
}
@@ -216,7 +217,7 @@ export class UserImportBuilder {
216217
private requiresHashOptions: boolean;
217218
private validatedUsers: UploadAccountUser[];
218219
private validatedOptions: UploadAccountOptions;
219-
private indexMap: object;
220+
private indexMap: {[key: number]: number};
220221
private userImportResultErrors: FirebaseArrayIndexError[];
221222

222223
/**

src/firebase-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class FirebaseApp {
274274

275275
Object.keys(firebaseInternals_.serviceFactories).forEach((serviceName) => {
276276
// Defer calling createService() until the service is accessed
277-
this[serviceName] = this.getService_.bind(this, serviceName);
277+
(this as {[key: string]: any})[serviceName] = this.getService_.bind(this, serviceName);
278278
});
279279

280280
this.INTERNAL = new FirebaseAppInternals(this.options_.credential);

src/firebase-namespace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class FirebaseNamespaceInternals {
6565
private apps_: {[appName: string]: FirebaseApp} = {};
6666
private appHooks_: {[service: string]: AppHook} = {};
6767

68-
constructor(public firebase_) {}
68+
constructor(public firebase_: {[key: string]: any}) {}
6969

7070
/**
7171
* Initializes the FirebaseApp instance.

0 commit comments

Comments
 (0)