Repository navigation
fix(app): export ./dist/module/types/* so storage, messaging and app-check types resolve - #9524
harpreetkbadhan wants to merge 2 commits into
Conversation
…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.
Mastersam07
left a comment
There was a problem hiding this comment.
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: addCompleteFn,NextFnandUnsubscribetoextraInRN. A reason along the lines of "re-export of the@react-native-firebase/appcommon type used byUploadTask.on()andStorageObserver; the firebase-js-sdk does not export it from @firebase/storage" works..github/scripts/compare-types/configs/app-check.ts: remove thePartialObserverandUnsubscribeentries frommissingInRN. 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!
|
Also ran |
…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.
|
Thanks for checking it so thoroughly. Pushed:
|
|
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Description
@react-native-firebase/storage,messagingandapp-checkimport types from@react-native-firebase/app/dist/module/types/common(andauth/storagefrom.../types/internal), but app'sexportsmap has no entry for./dist/module/types/*. UndermoduleResolution: "bundler"that import fails with TS2307, and withskipLibCheck: true(Expo's default) the types silently becomeany.This adds a
./dist/module/types/*entry modelled on./dist/module/common/*, as agreed in the issue. The three imports stay as they are.nodenextis out of scope (TS2834 on extensionless relative imports, tracked separately).tsconfig.consumer.jsonhadpathsaliases for these two subpaths, which is why the consumer check never caught it. They are removed so consumer code resolves the subpaths throughexportslike an app does, and a newpackages/storage/consumer-type-test.tsfails (unused@ts-expect-error) whenUnsubscribe,NextFn,CompleteFnorUploadTask.on()'s result lose their types.Related issues
Fixes #9518
Release Summary
Types imported by storage, messaging and app-check from
@react-native-firebase/appnow resolve undermoduleResolution: "bundler"instead of becomingany.Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__packages/storage/consumer-type-test.ts(run byyarn tsc:compile:consumer)Test Plan
yarn tsc:compile:consumer: fails before theexportsentry (4 × TS2578 unused@ts-expect-error), passes after.--traceResolutionshows bothtypes/commonandtypes/internalresolving throughexportstodist/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.