From b3c5b0b8e6f4e7c08958e300d47284285cf1e75c Mon Sep 17 00:00:00 2001 From: Armando Navarro Date: Tue, 7 Jul 2026 18:02:23 -0700 Subject: [PATCH] fix(schematics): only emit FirebaseOptions keys in the generated app config The Firebase CLI's apps.sdkconfig response includes management-API fields (projectNumber, version, locationId) alongside the web app config. The schematic only deleted locationId and inlined the rest into initializeApp(), so the generated app failed to compile with TS2769: 'projectNumber' does not exist in type 'FirebaseOptions'. Keep only the keys FirebaseOptions accepts, so future additions to the CLI response cannot break the generated config again. --- src/schematics/setup/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/schematics/setup/index.ts b/src/schematics/setup/index.ts index 06e29f789..3d40ed132 100644 --- a/src/schematics/setup/index.ts +++ b/src/schematics/setup/index.ts @@ -18,6 +18,12 @@ import { } from '../utils'; import { appPrompt, featuresPrompt, projectPrompt, userPrompt } from './prompts'; +// FirebaseOptions keys — apps.sdkconfig responses include management-API extras that initializeApp() rejects. +const firebaseOptionsKeys = [ + 'apiKey', 'authDomain', 'databaseURL', 'projectId', 'storageBucket', + 'messagingSenderId', 'appId', 'measurementId', 'recaptchaSiteKey', +]; + export interface SetupConfig extends DeployOptions { firebaseProject: FirebaseProject, firebaseApp?: FirebaseApp, @@ -92,8 +98,11 @@ export const ngAddSetupProject = ( firebaseApp = await appPrompt(firebaseProject, undefined, { projectRoot }); const result = await firebaseTools.apps.sdkconfig('web', firebaseApp.appId, { nonInteractive: true, projectRoot }); - sdkConfig = result.sdkConfig; - delete sdkConfig.locationId; + sdkConfig = Object.fromEntries( + firebaseOptionsKeys + .filter(key => result.sdkConfig[key] !== undefined) + .map(key => [key, result.sdkConfig[key]]) + ); setupConfig.sdkConfig = sdkConfig; setupConfig.firebaseApp = firebaseApp; // set up data connect locally if data connect hasn't already been initialized.