I just upgraded my angular application to 18.0.1 and got this error
TS2345: Argument of type 'EnvironmentProviders' is not assignable to parameter of type 'ImportProvidersSource'. [plugin angular-compiler]
[ng]
[ng] src/main.ts:63:47:
[ng] 63 │ ...orRoot(), provideFirebaseApp(() => initializeApp(environment.fi...
Following is my code in main.ts
main.ts
import { enableProdMode, importProvidersFrom, isDevMode } from "@angular/core";
import { bootstrapApplication } from "@angular/platform-browser";
import "zone.js";
import {
RouteReuseStrategy,
provideRouter
} from "@angular/router";
import { IonicModule, IonicRouteStrategy } from "@ionic/angular";
import { providePerformance, getPerformance } from "@angular/fire/performance";
import { routes } from "./app/app.routes";
import { AppComponent } from "./app/app.component";
import { environment } from "./environments/environment";
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptors, withInterceptorsFromDi } from "@angular/common/http";
import { getApp, initializeApp, provideFirebaseApp } from "@angular/fire/app";
import {
getAuth,
indexedDBLocalPersistence,
initializeAuth,
provideAuth,
} from "@angular/fire/auth";
import { getFirestore, provideFirestore } from "@angular/fire/firestore";
import { provideStorage, getStorage } from "@angular/fire/storage";
import {
provideRemoteConfig,
getRemoteConfig,
} from "@angular/fire/remote-config";
import { provideMessaging, getMessaging } from "@angular/fire/messaging";
import { provideFunctions, getFunctions } from "@angular/fire/functions";
import { Capacitor } from "@capacitor/core";
import { FirebaseAuthentication } from "@awesome-cordova-plugins/firebase-authentication/ngx";
import { CacheInterceptor } from "./app/classes/interceptor/cache.interceptor";
import { ApiLibModule } from "api-package";
import { ErrorInterceptor } from "./app/classes/interceptor/error.interceptor";
import { CustomHeaderInterceptor } from "./app/classes/interceptor/custom-header.interceptor";
import { provideServiceWorker } from '@angular/service-worker';
if (environment.production) {
enableProdMode();
}
bootstrapApplication(AppComponent, {
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
FirebaseAuthentication,
ApiLibModule,
provideHttpClient(withInterceptorsFromDi()),
{
provide: HTTP_INTERCEPTORS,
useClass: CacheInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: CustomHeaderInterceptor,
multi: true,
},
importProvidersFrom(IonicModule.forRoot(), provideFirebaseApp(() => initializeApp(environment.firebase)), provideAuth(() => {
if (Capacitor.isNativePlatform()) {
return initializeAuth(getApp(), {
persistence: indexedDBLocalPersistence,
});
}
else {
return getAuth(getApp());
}
}), provideFirestore(() => getFirestore()), provideFunctions(() => getFunctions()), provideMessaging(() => getMessaging()), providePerformance(() => getPerformance()), provideRemoteConfig(() => getRemoteConfig()), provideStorage(() => getStorage())),
provideRouter(routes),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})
],
});
@angular/fire
is 17.0.1 and I still have the same error. The most annoying fact is that I have another project that uses the same and there is no such error. I have already copiedpackage.json
definitions from there but still no luck. – Vidda