Repository navigation
fix(storage): give the compat fromTask an explicit return type - #3796
Open
armando-navarro wants to merge 1 commit into
Open
armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
fromTask declared no return type, so the published typings import whatever path the typings bundler picks for the inferred firebase type. In 20.x that is 'firebase/compat', which firebase's exports map does not list. Apps using moduleResolution "bundler", the setting the @angular/build migration moves apps to, fail with TS2307 in @angular/fire/compat/storage. 21.0.0-rc.1 happens to emit 'firebase/compat/app' and compiles, but ng-packagr 22.2's new typings bundler cannot parse the inferred type and fails the library build. Declaring Observable<UploadTaskSnapshot> removes the inferred import. The type is unchanged: UploadTaskSnapshot is the compat alias for firebase.storage.UploadTaskSnapshot. Also drop a comment explaining a firebase import that angular#3421 removed in 2023 as unused. The import only existed to steer these typings. Fixes angular#3677
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3677
This gives the compat
fromTaskan explicit return type, so the published@angular/fire/compat/storagetypings stop depending on how the typings bundler names an inferred Firebase type.Changes
fromTaskinsrc/compat/storage/observable/fromTask.tsdeclaresObservable<UploadTaskSnapshot>. The type is unchanged:UploadTaskSnapshotis the compat alias forfirebase.storage.UploadTaskSnapshot.firebaseimport that add eslint #3421 removed in 2023.20.1.x, so a 20.1 patch release fixes @angular/build: TS2307: Cannot find module 'firebase/compat' #3677 for apps on thelatesttag.Why
Without a declared return type, the typings import whatever module path the bundler picks for the inferred type:
'firebase/compat'. Thefirebasepackage'sexportsmap has no./compatentry, so apps usingmoduleResolution: "bundler"fail withTS2307: Cannot find module 'firebase/compat'. Angular'suse-application-buildermigration switches apps to that setting, which is how @angular/build: TS2307: Cannot find module 'firebase/compat' #3677 ran into it.'firebase/compat/app', which resolves, so it compiles.rolldown-plugin-dts. It cannot parse the inferred type, and the library build fails withPARSE_ERRORinfromTask.d.ts.Verification
fromTask, compiled withtsc5.9.3 andmoduleResolution: "bundler": the 20.0.1 and 20.1.0 typings fail with the error in @angular/build: TS2307: Cannot find module 'firebase/compat' #3677, and the 21.0.0-rc.1 typings and this branch's build compile. Withnode10resolution all of them compile, which matches the report that the older builder works.mainwith the Angular 22 upgrade applied (Angular 22.2.1, ng-packagr 22.2.4) fails to build withPARSE_ERRORinfromTask.d.ts, and builds once the return type is added.There are no new tests, since a declared return type has no runtime behavior. The Angular 22 build covers it once that upgrade lands.