firebase-js-sdk
firebase-js-sdk copied to clipboard
Remove prototype overrides in `FirebaseError` and all subclasses
We override the prototype of this
in all of the constructors for our custom error classes. This allowed us to adjust the prototype chain, so that we can perform instanceof
checks on subclasses of Error
.
Since ES2015, the built-in Error
constructor uses new.target
to adjust the prototype chain for us, so we no longer need to do it ourselves.
See https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work (the link doesn't work well since the linked header is hidden behind a rolled up section that can be expanded by clicking "See Changes for Older Releases" at the bottom).
Since new.target
does not exist in ES5, the prototype chain won't be adjusted if our bundle is transpiled down to ES5.