Skip to content

fix(app): export ./dist/module/types/* so storage, messaging and app-check types resolve - #9524

Open
harpreetkbadhan wants to merge 2 commits into
invertase:mainfrom
harpreetkbadhan:fix/app-exports-types
Open

harpreetkbadhan wants to merge 2 commits into
invertase:mainfrom
harpreetkbadhan:fix/app-exports-types

Conversation

@harpreetkbadhan

Copy link
Copy Markdown

Description

@react-native-firebase/storage, messaging and app-check import types from @react-native-firebase/app/dist/module/types/common (and auth / storage from .../types/internal), but app's exports map has no entry for ./dist/module/types/*. Under moduleResolution: "bundler" that import fails with TS2307, and with skipLibCheck: true (Expo's default) the types silently become any.

This adds a ./dist/module/types/* entry modelled on ./dist/module/common/*, as agreed in the issue. The three imports stay as they are. nodenext is out of scope (TS2834 on extensionless relative imports, tracked separately).

tsconfig.consumer.json had paths aliases for these two subpaths, which is why the consumer check never caught it. They are removed so consumer code resolves the subpaths through exports like an app does, and a new packages/storage/consumer-type-test.ts fails (unused @ts-expect-error) when Unsubscribe, NextFn, CompleteFn or UploadTask.on()'s result lose their types.

Related issues

Fixes #9518

Release Summary

Types imported by storage, messaging and app-check from @react-native-firebase/app now resolve under moduleResolution: "bundler" instead of becoming any.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
    • Consumer type test added in packages/storage/consumer-type-test.ts (run by yarn tsc:compile:consumer)
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

  • yarn tsc:compile:consumer: fails before the exports entry (4 × TS2578 unused @ts-expect-error), passes after. --traceResolution shows both types/common and types/internal resolving through exports to dist/typescript/lib/types/*.d.ts.
  • yarn tsc:compile, yarn tsc:compile:test-expo, yarn docs:tsc:check, yarn lint:js, yarn lint:deps: pass.
  • yarn tests:jest --watchman=false packages/app/__tests__/expoPluginPackageExports.test.ts packages/storage/__tests__: 53/53.

…check types resolve

storage, messaging and app-check import types from @react-native-firebase/app/dist/module/types/common (auth and storage also from types/internal), but app's exports map had no entry for that subpath. Under moduleResolution bundler the import failed with TS2307, and with skipLibCheck the types silently became any.

Add a ./dist/module/types/* entry modelled on ./dist/module/common/*. Drop the tsconfig.consumer.json paths aliases that hid the gap, and add a storage consumer type test that fails when the types are lost.
@CLAassistant

CLAassistant commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Mastersam07 Mastersam07 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @harpreetkbadhan, the fix is spot on. The new ./dist/module/types/* entry matches the existing common/* and internal/* ones. Removing the paths aliases means tsc:compile:consumer now resolves these imports through exports, the way an app does. I checked the consumer test by taking the exports entry back out: it fails as it should, and with the entry back in, the storage types resolve properly in a standalone TypeScript 6 project using bundler.

One thing CI will flag once the workflows run: yarn compare:types now fails, because CompleteFn, NextFn and Unsubscribe really resolve now instead of becoming any. That's a good sign, but the type-comparison configs need updating:

  • .github/scripts/compare-types/configs/storage.ts: add CompleteFn, NextFn and Unsubscribe to extraInRN. A reason along the lines of "re-export of the @react-native-firebase/app common type used by UploadTask.on() and StorageObserver; the firebase-js-sdk does not export it from @firebase/storage" works.
  • .github/scripts/compare-types/configs/app-check.ts: remove the PartialObserver and Unsubscribe entries from missingInRN. They resolve now, so the tool reports them as stale.

Optional: messaging and app-check import from the same subpath, so a couple of @ts-expect-error checks in their own consumer-type-test.ts would cover them too. Happy to merge without that if you'd rather keep this PR small.

With the config update in, this looks good to go. Thanks again!

@Mastersam07

Mastersam07 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Also ran yarn attw:check against this branch: all packages pass and the Expo plugin smoke test passes, so the compare:types config update is the only change needed.

…check consumers

CompleteFn, NextFn and Unsubscribe now resolve in storage, so compare-types lists them under extraInRN and the storage usage docs name them. PartialObserver and Unsubscribe resolve in app-check, so they leave missingInRN. Messaging and app-check get consumer type tests that fail without the ./dist/module/types/* exports entry.
@harpreetkbadhan

Copy link
Copy Markdown
Author

Thanks for checking it so thoroughly. Pushed:

  • configs/storage.ts: CompleteFn, NextFn and Unsubscribe added to extraInRN with that reason. docs:member:check then asked for them in the storage docs, so the usage page now names them in the overview and the task.on section.
  • configs/app-check.ts: PartialObserver and Unsubscribe removed from missingInRN.
  • Added consumer-type-test.ts for messaging (Observer's error / complete) and app-check (Unsubscribe, PartialObserver). They fail without the exports entry and pass with it.

yarn compare:types, yarn docs:member:check and yarn tsc:compile:consumer pass locally.

@Mastersam07

Copy link
Copy Markdown
Contributor

Thanks for the quick turnaround, @harpreetkbadhan! The config updates, the docs additions and the new app-check and messaging consumer tests all look good. I re-ran tsc:compile:consumer, compare:types, docs:member:check, docs:tsc:check, attw:check and the lint checks on this commit and they all pass. Taking the exports entry back out makes all three consumer tests fail as expected. 🎉

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.24%. Comparing base (ce0f96f) to head (61e5d80).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9524      +/-   ##
============================================
- Coverage     75.53%   72.24%   -3.29%     
+ Complexity     2362     2361       -1     
============================================
  Files           633      456     -177     
  Lines         42025    26247   -15778     
  Branches       5287     4403     -884     
============================================
- Hits          31741    18959   -12782     
+ Misses         8716     6017    -2699     
+ Partials       1568     1271     -297     
Flag Coverage Δ
android-native 71.00% <ø> (-<0.01%) ⬇️
e2e-ts-android 53.90% <ø> (-0.05%) ⬇️
e2e-ts-ios ?
e2e-ts-macos 49.64% <ø> (+0.01%) ⬆️
ios-native ?
ios-ruby ?
jest 54.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛] storage types import @react-native-firebase/app/dist/module/types/common, which app's exports map does not expose

3 participants