Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prototype overrides in FirebaseError and all subclasses #8552

Open
wants to merge 2 commits into
base: v11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/hungry-glasses-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@firebase/vertexai': patch
'@firebase/storage': patch
'@firebase/auth': patch
'@firebase/util': patch
---

Remove prototype overrides in `FirebaseError` and all subclasses.
2 changes: 0 additions & 2 deletions packages/auth/src/mfa/mfa_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export class MultiFactorError
readonly user?: UserInternal
) {
super(error.code, error.message);
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, MultiFactorError.prototype);
this.customData = {
appName: auth.name,
tenantId: auth.tenantId ?? undefined,
Expand Down
3 changes: 0 additions & 3 deletions packages/storage/src/implementation/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export class StorageError extends FirebaseError {
`Firebase Storage: ${message} (${prependCode(code)})`
);
this._baseMessage = this.message;
// Without this, `instanceof StorageError`, in tests for example,
// returns false.
Object.setPrototypeOf(this, StorageError.prototype);
}

get status(): number {
Expand Down
6 changes: 0 additions & 6 deletions packages/util/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ export class FirebaseError extends Error {
) {
super(message);

// Fix For ES5
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
// TODO(dlarocque): Replace this with `new.target`: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
// which we can now use since we no longer target ES5.
Object.setPrototypeOf(this, FirebaseError.prototype);

// Maintains proper stack trace for where our error was thrown.
// Only available on V8.
if (Error.captureStackTrace) {
Expand Down
6 changes: 0 additions & 6 deletions packages/vertexai/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ export class VertexAIError extends FirebaseError {
Error.captureStackTrace(this, VertexAIError);
}

// Allows instanceof VertexAIError in ES5/ES6
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
// TODO(dlarocque): Replace this with `new.target`: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
// which we can now use since we no longer target ES5.
Object.setPrototypeOf(this, VertexAIError.prototype);

// Since Error is an interface, we don't inherit toString and so we define it ourselves.
this.toString = () => fullMessage;
}
Expand Down
Loading