Skip to content

Commit 9a2a541

Browse files
fix(schematics): only emit FirebaseOptions keys in the generated app config (#3707)
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.
1 parent e4e652f commit 9a2a541

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/schematics/setup/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import {
1818
} from '../utils';
1919
import { appPrompt, featuresPrompt, projectPrompt, userPrompt } from './prompts';
2020

21+
// FirebaseOptions keys — apps.sdkconfig responses include management-API extras that initializeApp() rejects.
22+
const firebaseOptionsKeys = [
23+
'apiKey', 'authDomain', 'databaseURL', 'projectId', 'storageBucket',
24+
'messagingSenderId', 'appId', 'measurementId', 'recaptchaSiteKey',
25+
];
26+
2127
export interface SetupConfig extends DeployOptions {
2228
firebaseProject: FirebaseProject,
2329
firebaseApp?: FirebaseApp,
@@ -92,8 +98,11 @@ export const ngAddSetupProject = (
9298
firebaseApp = await appPrompt(firebaseProject, undefined, { projectRoot });
9399

94100
const result = await firebaseTools.apps.sdkconfig('web', firebaseApp.appId, { nonInteractive: true, projectRoot });
95-
sdkConfig = result.sdkConfig;
96-
delete sdkConfig.locationId;
101+
sdkConfig = Object.fromEntries(
102+
firebaseOptionsKeys
103+
.filter(key => result.sdkConfig[key] !== undefined)
104+
.map(key => [key, result.sdkConfig[key]])
105+
);
97106
setupConfig.sdkConfig = sdkConfig;
98107
setupConfig.firebaseApp = firebaseApp;
99108
// set up data connect locally if data connect hasn't already been initialized.

0 commit comments

Comments
 (0)