Skip to content

Commit b9d4c49

Browse files
authored
Merge 527d58e into ebc17e2
2 parents ebc17e2 + 527d58e commit b9d4c49

File tree

12 files changed

+26
-15
lines changed

12 files changed

+26
-15
lines changed

.changeset/olive-beds-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/analytics': patch
3+
---
4+
5+
Fix typo in GtagConfigParams

packages/analytics/src/initialize-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function validateIndexedDB(): Promise<boolean> {
4343
} catch (e) {
4444
logger.warn(
4545
ERROR_FACTORY.create(AnalyticsError.INDEXEDDB_UNAVAILABLE, {
46-
errorInfo: e
46+
errorInfo: (e as Error)?.toString()
4747
}).message
4848
);
4949
return false;

packages/auth-compat/src/user_credential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function attachExtraErrorFields(auth: exp.Auth, e: FirebaseError): void {
3333
// actually match the underlying type
3434
const response = (e.customData as exp.TaggedWithTokenResponse | undefined)
3535
?._tokenResponse as unknown as Record<string, string>;
36-
if (e.code === 'auth/multi-factor-auth-required') {
36+
if ((e as FirebaseError)?.code === 'auth/multi-factor-auth-required') {
3737
const mfaErr = e as compat.MultiFactorError;
3838
mfaErr.resolver = new MultiFactorResolver(
3939
auth,

packages/auth/src/core/auth/auth_impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import {
3636
createSubscribe,
3737
ErrorFactory,
38+
FirebaseError,
3839
getModularInstance,
3940
Observer,
4041
Subscribe
@@ -301,7 +302,7 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
301302
try {
302303
await _reloadWithoutSaving(user);
303304
} catch (e) {
304-
if (e.code !== `auth/${AuthErrorCode.NETWORK_REQUEST_FAILED}`) {
305+
if ((e as FirebaseError)?.code !== `auth/${AuthErrorCode.NETWORK_REQUEST_FAILED}`) {
305306
// Something's wrong with the user's token. Log them out and remove
306307
// them from storage
307308
return this.directlySetCurrentUser(null);

packages/auth/src/core/user/id_token_result.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function _parseToken(token: string): ParsedToken | null {
110110
}
111111
return JSON.parse(decoded);
112112
} catch (e) {
113-
_logError('Caught error parsing JWT payload as JSON', e);
113+
_logError('Caught error parsing JWT payload as JSON', (e as Error)?.toString());
114114
return null;
115115
}
116116
}

packages/auth/src/core/user/proactive_refresh.ts

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

18+
import { FirebaseError } from '@firebase/util';
1819
import { UserInternal } from '../../model/user';
1920
import { AuthErrorCode } from '../errors';
2021

@@ -92,7 +93,7 @@ export class ProactiveRefresh {
9293
await this.user.getIdToken(true);
9394
} catch (e) {
9495
// Only retry on network errors
95-
if (e.code === `auth/${AuthErrorCode.NETWORK_REQUEST_FAILED}`) {
96+
if ((e as FirebaseError)?.code === `auth/${AuthErrorCode.NETWORK_REQUEST_FAILED}`) {
9697
this.schedule(/* wasError */ true);
9798
}
9899

packages/auth/src/core/user/reauthenticate.ts

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

18+
import { FirebaseError } from '@firebase/util';
1819
import { _processCredentialSavingMfaContextIfNecessary } from '../../mfa/mfa_error';
1920
import { OperationType } from '../../model/enums';
2021
import { UserInternal } from '../../model/user';
@@ -54,7 +55,7 @@ export async function _reauthenticate(
5455
return UserCredentialImpl._forOperation(user, operationType, response);
5556
} catch (e) {
5657
// Convert user deleted error into user mismatch
57-
if (e?.code === `auth/${AuthErrorCode.USER_DELETED}`) {
58+
if ((e as FirebaseError)?.code === `auth/${AuthErrorCode.USER_DELETED}`) {
5859
_fail(auth, AuthErrorCode.USER_MISMATCH);
5960
}
6061
throw e;

packages/auth/src/mfa/mfa_user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { UserInternal } from '../model/user';
2929
import { MultiFactorAssertionImpl } from './mfa_assertion';
3030
import { MultiFactorInfoImpl } from './mfa_info';
3131
import { MultiFactorSessionImpl } from './mfa_session';
32-
import { getModularInstance } from '@firebase/util';
32+
import { FirebaseError, getModularInstance } from '@firebase/util';
3333

3434
export class MultiFactorUserImpl implements MultiFactorUser {
3535
enrolledFactors: MultiFactorInfo[] = [];
@@ -94,7 +94,7 @@ export class MultiFactorUserImpl implements MultiFactorUser {
9494
try {
9595
await this.user.reload();
9696
} catch (e) {
97-
if (e.code !== `auth/${AuthErrorCode.TOKEN_EXPIRED}`) {
97+
if ((e as FirebaseError)?.code !== `auth/${AuthErrorCode.TOKEN_EXPIRED}`) {
9898
throw e;
9999
}
100100
}

packages/auth/src/platform_browser/providers/phone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class PhoneAuthProvider {
179179
* auth.currentUser,
180180
* PhoneAuthProvider.credential(verificationId, code));
181181
* } catch (e) {
182-
* if (e.code === 'auth/account-exists-with-different-credential') {
182+
* if ((e as FirebaseError)?.code === 'auth/account-exists-with-different-credential') {
183183
* const cred = PhoneAuthProvider.credentialFromError(e);
184184
* await linkWithCredential(auth.currentUser, cred);
185185
* }

packages/remote-config/src/errors.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,8 @@ export const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(
9696

9797
// Note how this is like typeof/instanceof, but for ErrorCode.
9898
export function hasErrorCode(e: Error, errorCode: ErrorCode): boolean {
99-
return e instanceof FirebaseError && e.code.indexOf(errorCode) !== -1;
99+
return (
100+
e instanceof FirebaseError &&
101+
(e as FirebaseError)?.code.indexOf(errorCode) !== -1
102+
);
100103
}

packages/util/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*
5050
* catch (e) {
5151
* assert(e.message === "Could not find file: foo.txt.");
52-
* if (e.code === 'service/file-not-found') {
52+
* if ((e as FirebaseError)?.code === 'service/file-not-found') {
5353
* console.log("Could not read file: " + e['file']);
5454
* }
5555
* }

packages/util/test/errors.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ describe('FirebaseError', () => {
4848
const e = ERROR_FACTORY.create('generic-error');
4949
assert.instanceOf(e, Error);
5050
assert.instanceOf(e, FirebaseError);
51-
assert.equal(e.code, 'fake/generic-error');
51+
assert.equal((e as FirebaseError)?.code, 'fake/generic-error');
5252
assert.equal(e.message, 'Fake: Unknown error (fake/generic-error).');
5353
});
5454

5555
it('replaces template values with data', () => {
5656
const e = ERROR_FACTORY.create('file-not-found', { file: 'foo.txt' });
57-
assert.equal(e.code, 'fake/file-not-found');
57+
assert.equal((e as FirebaseError)?.code, 'fake/file-not-found');
5858
assert.equal(
5959
e.message,
6060
"Fake: Could not find file: 'foo.txt' (fake/file-not-found)."
@@ -65,15 +65,15 @@ describe('FirebaseError', () => {
6565
it('uses "Error" as template when template is missing', () => {
6666
// Cast to avoid compile-time error.
6767
const e = ERROR_FACTORY.create('no-such-code' as any as ErrorCode);
68-
assert.equal(e.code, 'fake/no-such-code');
68+
assert.equal((e as FirebaseError)?.code, 'fake/no-such-code');
6969
assert.equal(e.message, 'Fake: Error (fake/no-such-code).');
7070
});
7171

7272
it('uses the key in the template if the replacement is missing', () => {
7373
const e = ERROR_FACTORY.create('file-not-found', {
7474
fileX: 'foo.txt'
7575
} as any);
76-
assert.equal(e.code, 'fake/file-not-found');
76+
assert.equal((e as FirebaseError)?.code, 'fake/file-not-found');
7777
assert.equal(
7878
e.message,
7979
"Fake: Could not find file: '<file?>' (fake/file-not-found)."

0 commit comments

Comments
 (0)