Skip to content

Commit

Permalink
fix: try to support Angular 14
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Jan 5, 2023
1 parent 59ee390 commit 59abc50
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions projects/angular-auth-oidc-client/src/lib/provide-auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeEnvironmentProviders, Provider } from '@angular/core';
import * as ngCore from '@angular/core';
import { DataService } from './api/data.service';
import { HttpBaseService } from './api/http-base.service';
import { createStaticLoader, PassedInitialConfig, PASSED_CONFIG } from './auth-config';
Expand Down Expand Up @@ -63,10 +63,14 @@ declare type EnvironmentProviders = {
};

export function provideAuth(passedConfig: PassedInitialConfig): EnvironmentProviders {
return makeEnvironmentProviders([..._provideAuth(passedConfig)]);
if (!('makeEnvironmentProviders' in ngCore)) {
throw Error('provideAuth can only be used with Angular 15');
}

return ngCore['makeEnvironmentProviders']([..._provideAuth(passedConfig)]);
}

export function _provideAuth(passedConfig: PassedInitialConfig): Provider[] {
export function _provideAuth(passedConfig: PassedInitialConfig): ngCore.Provider[] {
return [
// Make the PASSED_CONFIG available through injection
{ provide: PASSED_CONFIG, useValue: passedConfig },
Expand Down

0 comments on commit 59abc50

Please sign in to comment.