diff --git a/packages/analytics/src/index.ts b/packages/analytics/src/index.ts index 0fc2a8e2b0a..69e024c3311 100644 --- a/packages/analytics/src/index.ts +++ b/packages/analytics/src/index.ts @@ -82,7 +82,7 @@ function registerAnalytics(): void { }; } catch (e) { throw ERROR_FACTORY.create(AnalyticsError.INTEROP_COMPONENT_REG_FAILED, { - reason: e + reason: e as Error }); } } diff --git a/packages/auth/src/core/auth/middleware.ts b/packages/auth/src/core/auth/middleware.ts index 01fe8e40168..2f5fa3a5065 100644 --- a/packages/auth/src/core/auth/middleware.ts +++ b/packages/auth/src/core/auth/middleware.ts @@ -87,7 +87,7 @@ export class AuthMiddlewareQueue { } throw this.auth._errorFactory.create( - AuthErrorCode.LOGIN_BLOCKED, { originalMessage: e.message }); + AuthErrorCode.LOGIN_BLOCKED, { originalMessage: (e as Error)?.message }); } } -} \ No newline at end of file +} diff --git a/packages/auth/test/integration/flows/phone.test.ts b/packages/auth/test/integration/flows/phone.test.ts index 2711292d046..389fb9e5947 100644 --- a/packages/auth/test/integration/flows/phone.test.ts +++ b/packages/auth/test/integration/flows/phone.test.ts @@ -294,7 +294,7 @@ describe('Integration test: phone auth', () => { ) ); } catch (e) { - error = e; + error = e as FirebaseError; } expect(error!.customData!.phoneNumber).to.eq(PHONE_A.phoneNumber); diff --git a/packages/firestore-compat/src/api/database.ts b/packages/firestore-compat/src/api/database.ts index bf5715ee43d..f4e63c09d77 100644 --- a/packages/firestore-compat/src/api/database.ts +++ b/packages/firestore-compat/src/api/database.ts @@ -297,7 +297,11 @@ export class Firestore collection(this._delegate, pathString) ); } catch (e) { - throw replaceFunctionName(e, 'collection()', 'Firestore.collection()'); + throw replaceFunctionName( + e as Error, + 'collection()', + 'Firestore.collection()' + ); } } @@ -305,7 +309,7 @@ export class Firestore try { return new DocumentReference(this, doc(this._delegate, pathString)); } catch (e) { - throw replaceFunctionName(e, 'doc()', 'Firestore.doc()'); + throw replaceFunctionName(e as Error, 'doc()', 'Firestore.doc()'); } } @@ -314,7 +318,7 @@ export class Firestore return new Query(this, collectionGroup(this._delegate, collectionId)); } catch (e) { throw replaceFunctionName( - e, + e as Error, 'collectionGroup()', 'Firestore.collectionGroup()' ); @@ -687,7 +691,7 @@ export class DocumentReference ); } catch (e) { throw replaceFunctionName( - e, + e as Error, 'collection()', 'DocumentReference.collection()' ); @@ -718,7 +722,11 @@ export class DocumentReference return setDoc(this._delegate, value as WithFieldValue); } } catch (e) { - throw replaceFunctionName(e, 'setDoc()', 'DocumentReference.set()'); + throw replaceFunctionName( + e as Error, + 'setDoc()', + 'DocumentReference.set()' + ); } } @@ -745,7 +753,11 @@ export class DocumentReference ); } } catch (e) { - throw replaceFunctionName(e, 'updateDoc()', 'DocumentReference.update()'); + throw replaceFunctionName( + e as Error, + 'updateDoc()', + 'DocumentReference.update()' + ); } } @@ -991,7 +1003,11 @@ export class Query query(this._delegate, where(fieldPath as string, opStr, value)) ); } catch (e) { - throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()'); + throw replaceFunctionName( + e as Error, + /(orderBy|where)\(\)/, + 'Query.$1()' + ); } } @@ -1008,7 +1024,11 @@ export class Query query(this._delegate, orderBy(fieldPath as string, directionStr)) ); } catch (e) { - throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()'); + throw replaceFunctionName( + e as Error, + /(orderBy|where)\(\)/, + 'Query.$1()' + ); } } @@ -1016,7 +1036,7 @@ export class Query try { return new Query(this.firestore, query(this._delegate, limit(n))); } catch (e) { - throw replaceFunctionName(e, 'limit()', 'Query.limit()'); + throw replaceFunctionName(e as Error, 'limit()', 'Query.limit()'); } } @@ -1027,7 +1047,11 @@ export class Query query(this._delegate, limitToLast(n)) ); } catch (e) { - throw replaceFunctionName(e, 'limitToLast()', 'Query.limitToLast()'); + throw replaceFunctionName( + e as Error, + 'limitToLast()', + 'Query.limitToLast()' + ); } } @@ -1035,7 +1059,7 @@ export class Query try { return new Query(this.firestore, query(this._delegate, startAt(...args))); } catch (e) { - throw replaceFunctionName(e, 'startAt()', 'Query.startAt()'); + throw replaceFunctionName(e as Error, 'startAt()', 'Query.startAt()'); } } @@ -1046,7 +1070,11 @@ export class Query query(this._delegate, startAfter(...args)) ); } catch (e) { - throw replaceFunctionName(e, 'startAfter()', 'Query.startAfter()'); + throw replaceFunctionName( + e as Error, + 'startAfter()', + 'Query.startAfter()' + ); } } @@ -1057,7 +1085,7 @@ export class Query query(this._delegate, endBefore(...args)) ); } catch (e) { - throw replaceFunctionName(e, 'endBefore()', 'Query.endBefore()'); + throw replaceFunctionName(e as Error, 'endBefore()', 'Query.endBefore()'); } } @@ -1065,7 +1093,7 @@ export class Query try { return new Query(this.firestore, query(this._delegate, endAt(...args))); } catch (e) { - throw replaceFunctionName(e, 'endAt()', 'Query.endAt()'); + throw replaceFunctionName(e as Error, 'endAt()', 'Query.endAt()'); } } @@ -1265,7 +1293,11 @@ export class CollectionReference ); } } catch (e) { - throw replaceFunctionName(e, 'doc()', 'CollectionReference.doc()'); + throw replaceFunctionName( + e as Error, + 'doc()', + 'CollectionReference.doc()' + ); } } diff --git a/packages/firestore/src/core/event_manager.ts b/packages/firestore/src/core/event_manager.ts index 33924b45923..ecce1109150 100644 --- a/packages/firestore/src/core/event_manager.ts +++ b/packages/firestore/src/core/event_manager.ts @@ -97,7 +97,7 @@ export async function eventManagerListen( queryInfo.viewSnap = await eventManagerImpl.onListen(query); } catch (e) { const firestoreError = wrapInUserErrorIfRecoverable( - e, + e as Error, `Initialization of query '${stringifyQuery(listener.query)}' failed` ); listener.onError(firestoreError); diff --git a/packages/messaging/src/helpers/registerDefaultSw.ts b/packages/messaging/src/helpers/registerDefaultSw.ts index 2d929596c68..239e6ed8244 100644 --- a/packages/messaging/src/helpers/registerDefaultSw.ts +++ b/packages/messaging/src/helpers/registerDefaultSw.ts @@ -41,7 +41,7 @@ export async function registerDefaultSw( }); } catch (e) { throw ERROR_FACTORY.create(ErrorCode.FAILED_DEFAULT_REGISTRATION, { - browserErrorMessage: e.message + browserErrorMessage: (e as Error)?.message }); } } diff --git a/repo-scripts/api-documenter/src/plugin/PluginLoader.ts b/repo-scripts/api-documenter/src/plugin/PluginLoader.ts index fc02d35190d..3bf868c86e2 100644 --- a/repo-scripts/api-documenter/src/plugin/PluginLoader.ts +++ b/repo-scripts/api-documenter/src/plugin/PluginLoader.ts @@ -124,7 +124,8 @@ export class PluginLoader { ); } catch (e) { throw new Error( - `Failed to construct feature subclass:\n` + e.toString() + `Failed to construct feature subclass:\n` + + (e as Error)?.toString() ); } if ( @@ -140,7 +141,7 @@ export class PluginLoader { } catch (e) { throw new Error( 'Error occurred during the onInitialized() event: ' + - e.toString() + (e as Error)?.toString() ); } @@ -153,7 +154,8 @@ export class PluginLoader { } } catch (e) { throw new Error( - `Error loading plugin ${configPlugin.packageName}: ` + e.message + `Error loading plugin ${configPlugin.packageName}: ` + + (e as Error)?.message ); } } diff --git a/scripts/ci/check_changeset.ts b/scripts/ci/check_changeset.ts index d9d92688ebf..b5c8fd7e075 100644 --- a/scripts/ci/check_changeset.ts +++ b/scripts/ci/check_changeset.ts @@ -126,10 +126,11 @@ async function main() { await exec(`yarn changeset status`); console.log(`::set-output name=BLOCKING_FAILURE::false`); } catch (e) { - if (e.message.match('No changesets present')) { + const error = e as Error; + if (error.message.match('No changesets present')) { console.log(`::set-output name=BLOCKING_FAILURE::false`); } else { - const messageLines = e.message.replace(/🦋 error /g, '').split('\n'); + const messageLines = error.message.replace(/🦋 error /g, '').split('\n'); let formattedStatusError = '- Changeset formatting error in following file:%0A'; formattedStatusError += ' ```%0A';