Skip to content

docs: fix broken code snippets in product guides - #3732

Open
armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:docs-product-snippet-fixes
Open

docs: fix broken code snippets in product guides#3732
armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:docs-product-snippet-fixes

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Description

Fixes the broken copy-paste code samples in the modular product guides. Each change makes the sample compile or parse as written, so a developer can copy it directly.

  • Close the appConfig object literal with } (was })) in the App Check, Auth, Database, Functions, Messaging, Remote Config, Storage, and Performance guides.
  • Import ApplicationConfig in every appConfig sample so the type annotation resolves.
  • App Check: import getApp, which the sample calls.
  • Firestore: correct export Interface to export interface (twice), import Observable from rxjs, and import CollectionReference and DocumentReference.
  • Auth and Database: replace the @NgModule emulator and multiple-instance samples with the standalone appConfig form the rest of the guides teach, and inline the Firebase config instead of reading environment.firebase, which the current ng add setup does not generate.
  • Messaging: repair the FcmService example (declare message$, move its assignment into the constructor, make deleteToken async) and bump the service-worker CDN imports from 9.22.0 to 12.4.0 to match the firebase dependency.

Documentation only, no source or API changes.

Checklist

Fixes #3731
Refs #3369

Several product-guide snippets did not compile or parse as written, so a
reader copying them hit errors before reaching Firebase.

- Close the appConfig object literal with } instead of }) in the App
  Check, Auth, Database, Functions, Messaging, Remote Config, Storage,
  and Performance guides.
- Import ApplicationConfig in every appConfig snippet so the type
  annotation resolves.
- App Check: import getApp, which the snippet calls.
- Firestore: correct "export Interface" to "export interface" (twice),
  import Observable from rxjs, and import CollectionReference and
  DocumentReference.
- Auth and Database: replace the NgModule emulator and multi-instance
  examples with the standalone appConfig form the rest of the guides
  teach, and inline the Firebase config instead of reading a
  no-longer-generated environment file.
- Messaging: repair the FcmService example (declare message$, move its
  assignment into the constructor, make deleteToken async) and bump the
  service-worker CDN imports from 9.22.0 to 12.4.0 to match the firebase
  dependency.
@armando-navarro armando-navarro added comp: docs Documentation. type: chore Maintenance with no user-facing behavior change. labels Aug 3, 2026

@tyler-reitz tyler-reitz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice cleanup — these are the samples people copy first, so having them parse matters.

I pulled the branch and ran the repaired FcmService through tsc; the only remaining diagnostics are unresolved module specifiers from --noResolve, so the brace structure now parses where it previously did not. The 9.22.0 to 12.4.0 service-worker CDN bump matches the firebase: ^12.4.0 dependency. Returning onMessage's unsubscribe from the new Observable(...) subscriber function is also correct RxJS teardown, so that sample no longer leaks its listener.

Two nits, neither blocking:

  1. message$: Observable<unknown> loses the payload type a reader would want — Observable<MessagePayload> would be more useful as a starting point.
  2. Inside async deleteToken(), the call to the imported deleteToken(this.msg) is correct but reads like recursion at a glance. An import alias or a one-line comment would save the double-take.

Also worth noting for merge order: this and #3734 both touch docs/app-check.md and docs/auth.md with adjacent hunks. They don't duplicate each other, but whichever lands second should be rebased and re-skimmed rather than merged on a stale green.

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

Labels

comp: docs Documentation. type: chore Maintenance with no user-facing behavior change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: broken code samples in several product guides

2 participants