Skip to content

Commit e5177aa

Browse files
feat(store): make reducers arg of StoreModule.forRoot optional (#3632)
1 parent 24c086f commit e5177aa

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

modules/store/src/provide_store.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ export function provideState<T, V extends Action = Action>(
114114
}
115115

116116
export function _provideStore<T, V extends Action = Action>(
117-
reducers: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
118-
config: RootStoreConfig<T, V>
117+
reducers:
118+
| ActionReducerMap<T, V>
119+
| InjectionToken<ActionReducerMap<T, V>>
120+
| Record<string, never> = {},
121+
config: RootStoreConfig<T, V> = {}
119122
): Provider[] {
120123
return [
121124
{
@@ -211,7 +214,7 @@ export function provideStore<T, V extends Action = Action>(
211214
config?: RootStoreConfig<T, V>
212215
): EnvironmentProviders {
213216
return makeEnvironmentProviders([
214-
..._provideStore(reducers ?? ({} as ActionReducerMap<T, V>), config ?? {}),
217+
..._provideStore(reducers, config),
215218
ENVIRONMENT_STORE_PROVIDER,
216219
]);
217220
}

modules/store/src/store_module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ export class StoreFeatureModule implements OnDestroy {
8181
@NgModule({})
8282
export class StoreModule {
8383
static forRoot<T, V extends Action = Action>(
84-
reducers: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
84+
reducers?: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
8585
config?: RootStoreConfig<T, V>
8686
): ModuleWithProviders<StoreRootModule> {
8787
return {
8888
ngModule: StoreRootModule,
89-
providers: [..._provideStore(reducers, config ?? {})],
89+
providers: [..._provideStore(reducers, config)],
9090
};
9191
}
9292

0 commit comments

Comments
 (0)