-
Notifications
You must be signed in to change notification settings - Fork 927
Export StorageError class instead of interface #6974
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
Conversation
🦋 Changeset detectedLatest commit: f7dd97d The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
I'm generally okay with this, is this consistent with other Firebase sdks? |
Yes. Every other SDK (except Auth) uses Classes instead of interfaces |
…base/firebase-js-sdk into mtewani/export-storageerror
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the changes, please have someone from the core js team to approve too before submitting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually just realized I think we originally did this to make the type export neater and hide unnecessary stuff like the private members and the getters and setters but I guess there is no way around it if users want to use instanceof
.
packages/storage/src/public-types.ts
Outdated
import { CompleteFn, NextFn, Subscribe, Unsubscribe } from '@firebase/util'; | ||
import { StorageError } from './implementation/error'; | ||
|
||
export { StorageError, StorageErrorCode } from './implementation/error'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be exported directly from src/api.ts
. I think we had some weird bugs before when non-types were exported from a file that otherwise only exported types, but even if that's not a problem, just for organizational purposes.
common/api-review/storage.api.md
Outdated
} | ||
|
||
// @public | ||
export const enum StorageErrorCode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, wasn't paying attention earlier to a new enum being exported as well, I think there are some problems with exporting a const enum
(for a certain set of users) so I think this needs to be changed to just enum
here
export const enum StorageErrorCode { |
Background on const enum issues https://ncjamieson.com/dont-export-const-enums/
packages/storage-types/index.d.ts
Outdated
@@ -16,10 +16,10 @@ | |||
*/ | |||
|
|||
import { FirebaseApp } from '@firebase/app-types'; | |||
import { StorageError as FirebaseStorageError } from '@firebase/storage'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this will work, as (1) @firebase/storage
isn't a dependency of @firebase/storage-types
so it's not great to import from it. In practice it should always be there because users install all of Firebase at once, but it doesn't seem right and I think some of the newer package managers yell about this. (2) I think this is sort of exporting a class from a d.ts
file which I don't think you can do, not 100% sure, maybe it just treats it as a type. I know we were importing FirebaseError before which is a class but it was only used as an extends
for an interface, and that interface was what's exported. Hm, is there any way to make an interface from scratch here that matches the StorageError class?
Fixes #6944