Skip to content

fix(storage): give the compat fromTask an explicit return type - #3796

Open
armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:a69-fromtask-return-type
Open

armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:a69-fromtask-return-type

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Fixes #3677

This gives the compat fromTask an explicit return type, so the published @angular/fire/compat/storage typings stop depending on how the typings bundler names an inferred Firebase type.

Changes

  • fromTask in src/compat/storage/observable/fromTask.ts declares Observable<UploadTaskSnapshot>. The type is unchanged: UploadTaskSnapshot is the compat alias for firebase.storage.UploadTaskSnapshot.
  • Removes a comment explaining a firebase import that add eslint #3421 removed in 2023.
  • Once this merges, it will be cherry-picked to 20.1.x, so a 20.1 patch release fixes @angular/build: TS2307: Cannot find module 'firebase/compat' #3677 for apps on the latest tag.

Why

Without a declared return type, the typings import whatever module path the bundler picks for the inferred type:

  • 20.0.1 and 20.1.0 import 'firebase/compat'. The firebase package's exports map has no ./compat entry, so apps using moduleResolution: "bundler" fail with TS2307: Cannot find module 'firebase/compat'. Angular's use-application-builder migration switches apps to that setting, which is how @angular/build: TS2307: Cannot find module 'firebase/compat' #3677 ran into it.
  • 21.0.0-rc.1 happens to import 'firebase/compat/app', which resolves, so it compiles.
  • ng-packagr 22.2, which the Angular 22 upgrade brings in, bundles typings with rolldown-plugin-dts. It cannot parse the inferred type, and the library build fails with PARSE_ERROR in fromTask.d.ts.

Verification

  • A consumer importing fromTask, compiled with tsc 5.9.3 and moduleResolution: "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. With node10 resolution all of them compile, which matches the report that the older builder works.
  • main with the Angular 22 upgrade applied (Angular 22.2.1, ng-packagr 22.2.4) fails to build with PARSE_ERROR in fromTask.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.

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
@armando-navarro armando-navarro added backport: 20.1.x Cherry-pick onto the 20.1.x branch for a 20.1 patch release bump: patch Size of the change: a fix or docs change that reaches users comp: compat Compatibility layer for the pre-modular API (src/compat). comp: storage Cloud Storage (src/storage). comp: typings TypeScript type correctness across the public API. type: bug Defect: expected behavior doesn't happen. labels Oct 8, 2026
@armando-navarro armando-navarro added this to the 21.0.0-rc.2 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport: 20.1.x Cherry-pick onto the 20.1.x branch for a 20.1 patch release bump: patch Size of the change: a fix or docs change that reaches users comp: compat Compatibility layer for the pre-modular API (src/compat). comp: storage Cloud Storage (src/storage). comp: typings TypeScript type correctness across the public API. type: bug Defect: expected behavior doesn't happen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/build: TS2307: Cannot find module 'firebase/compat'

1 participant