Repository navigation
docs(firestore): type reads with a converter instead of a type argument - #3838
Merged
armando-navarro merged 2 commits intoNov 6, 2026
Merged
Conversation
The README, the quickstart and the v7 upgrade guide showed collectionData<Item>(collection(firestore, 'items')), which fails with TS2345: collection() returns a reference typed DocumentData and the type argument asks for Item. docs/firestore.md cast the result with `as Observable<UserProfile[]>` instead, which compiles but checks nothing. The examples now attach a FirestoreDataConverter through withConverter, the Firebase SDK's way to type a reference, with a fromFirestore that substitutes a default for a missing or wrong field. A new "Typed reads" section in docs/firestore.md says why the two shortcuts do not give a typed read, where the default-versus-throw choice lives, and that idField performs no validation.
This was referenced Nov 5, 2026
tyler-reitz
approved these changes
Nov 5, 2026
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.
Checklist
yarn install,yarn testrun successfully? Not run, the change is four Markdown files.npm run lintpassed on the commit.Description
The README, the quickstart (
docs/install-and-setup.md) and the v7 upgrade guide showcollectionData<Item>(collection(firestore, 'items')), which doesn't compile.collection()returns a reference typedDocumentData, andcollectionData<Item>asks forQuery<Item>, so TypeScript reports TS2345.docs/firestore.mdcasts instead,collectionData(ref) as Observable<UserProfile[]>, which compiles but checks nothing about the stored documents. #3081 and #3073 are readers asking for a typedcollection<T>(), and the thread workarounds are the cast and a helper service.The signature comes from the Firebase SDK, where the type lives on the reference through
withConverter()(see #2931). The docs now teach that.Changes
README.mdanddocs/install-and-setup.md: theItemexample attaches aFirestoreDataConverter<Item>whosefromFirestoresubstitutes''for a missing or non-stringname, reads throughcollection(...).withConverter(itemConverter), and callscollectionData()with no type argument. One sentence under the example links to the new section.docs/firestore.md: theUserProfileexample gets the same converter, the cast goes, and a new "Typed reads" subsection explains why the two shortcuts do not give a typed read, where the default-versus-throw choice lives (fromFirestoreruns on every document, so a throw there errors the observable at the first bad document), and thatidFieldperforms no validation.docs/version-7-upgrade.md: a sentence above the v6-to-v7 table definesdocRefas a converter-typed reference, thecollection<T>(docRef, 'bar') // CollectionReference<T>row is corrected (bothcollection(reference, path)overloads returnCollectionReference<DocumentData>),docData's return type gains| undefined, and the code-splitting snippet uses a converter and importsconcatMap.Checked on a fresh Angular 22.2.4 app with
@angular/fire22.0.0-rc.0: the quickstart text builds as written, the previouscollectionData<Item>(aCollection)line fails the same build with TS2345, and against the Firestore emulator the documented converter keeps emitting on malformed documents while a throwing one ends the subscription.Not changed:
site/src/get-started/quick-start.mdstill shows the cast.site/is the unbuilt duplicate docs tree whose fate is a separate decision.Fixes #3081
Fixes #3073