@@ -72,9 +72,9 @@ export class Firestore implements FirestoreService {
7272
7373 private _settings = new FirestoreSettingsImpl ( { } ) ;
7474 private _settingsFrozen = false ;
75- private _emulatorOptions ? : {
75+ private _emulatorOptions : {
7676 mockUserToken ?: EmulatorMockTokenOptions | string ;
77- } ;
77+ } = { } ;
7878
7979 // A task that is assigned when the terminate() is invoked and resolved when
8080 // all components have shut down. Otherwise, Firestore is not terminated,
@@ -123,7 +123,7 @@ export class Firestore implements FirestoreService {
123123 ) ;
124124 }
125125 this . _settings = new FirestoreSettingsImpl ( settings ) ;
126- this . _emulatorOptions = settings . emulatorOptions ;
126+ this . _emulatorOptions = settings . emulatorOptions || { } ;
127127
128128 if ( settings . credentials !== undefined ) {
129129 this . _authCredentials = makeAuthCredentialsProvider ( settings . credentials ) ;
@@ -134,15 +134,8 @@ export class Firestore implements FirestoreService {
134134 return this . _settings ;
135135 }
136136
137- _getPrivateSettings ( ) : PrivateSettings {
138- const privateSettings : PrivateSettings = {
139- ...this . _settings ,
140- emulatorOptions : this . _emulatorOptions
141- } ;
142- if ( this . _settings . localCache !== undefined ) {
143- privateSettings . localCache = this . _settings . localCache ;
144- }
145- return privateSettings ;
137+ _getEmulatorOptions ( ) : { mockUserToken ?: EmulatorMockTokenOptions | string } {
138+ return this . _emulatorOptions ;
146139 }
147140
148141 _freezeSettings ( ) : FirestoreSettingsImpl {
@@ -332,16 +325,20 @@ export function connectFirestoreEmulator(
332325 } = { }
333326) : void {
334327 firestore = cast ( firestore , Firestore ) ;
335- const settings = firestore . _getPrivateSettings ( ) ;
336- const newHostSetting = `${ host } :${ port } ` ;
328+ const settings = firestore . _getSettings ( ) ;
329+ const existingConfig = {
330+ ...settings ,
331+ emultorOptions : firestore . _getEmulatorOptions ( )
332+ } ;
337333
334+ const newHostSetting = `${ host } :${ port } ` ;
338335 if ( settings . host !== DEFAULT_HOST && settings . host !== newHostSetting ) {
339336 logWarn (
340337 'Host has been set in both settings() and connectFirestoreEmulator(), emulator host ' +
341338 'will be used.'
342339 ) ;
343340 }
344- const newSettings = {
341+ const newConfig = {
345342 ...settings ,
346343 host : newHostSetting ,
347344 ssl : false ,
@@ -350,13 +347,13 @@ export function connectFirestoreEmulator(
350347
351348 // No-op if the new configuration matches the current configuration. This supports SSR
352349 // enviornments which might call `connectFirestoreEmulator` multiple times as a standard practice.
353- if ( deepEqual ( newSettings , settings ) ) {
350+ if ( deepEqual ( newConfig , existingConfig ) ) {
354351 console . error ( 'DEDB settings are the same!' ) ;
355352 return ;
356353 }
357354 console . error ( 'DEDB settings differ!' ) ;
358355
359- firestore . _setSettings ( newSettings ) ;
356+ firestore . _setSettings ( newConfig ) ;
360357
361358 if ( options . mockUserToken ) {
362359 let token : string ;
0 commit comments