diff --git a/modules/store/src/feature_creator.ts b/modules/store/src/feature_creator.ts index d77ce90041..46597982db 100644 --- a/modules/store/src/feature_creator.ts +++ b/modules/store/src/feature_creator.ts @@ -87,6 +87,14 @@ export function createFeature< * @returns An object that contains a feature name, a feature reducer, * a feature selector, and a selector for each feature state property. */ +export function createFeature( + featureConfig: FeatureConfig & + NotAllowedFeatureStateCheck +): Feature, FeatureName, FeatureState>; +/** + * @deprecated Use the `createFeature` signature without root state instead. + * For more info see: https://github.com/ngrx/platform/issues/3737 + */ export function createFeature< AppState extends Record, FeatureName extends keyof AppState & string = keyof AppState & string, @@ -110,13 +118,7 @@ export function createFeature< * * @usageNotes * - * **With Application State** - * * ```ts - * interface AppState { - * products: ProductsState; - * } - * * interface ProductsState { * products: Product[]; * selectedId: string | null; @@ -127,8 +129,7 @@ export function createFeature< * selectedId: null, * }; * - * // AppState is passed as a generic argument - * const productsFeature = createFeature({ + * const productsFeature = createFeature({ * name: 'products', * reducer: createReducer( * initialState, @@ -140,24 +141,13 @@ export function createFeature< * }); * * const { - * selectProductsState, // type: MemoizedSelector - * selectProducts, // type: MemoizedSelector - * selectSelectedId, // type: MemoizedSelector - * } = productsFeature; - * ``` - * - * **Without Application State** - * - * ```ts - * const productsFeature = createFeature({ - * name: 'products', - * reducer: createReducer(initialState), - * }); - * - * const { + * name, + * reducer, + * // feature selector * selectProductsState, // type: MemoizedSelector, ProductsState> + * // feature state properties selectors * selectProducts, // type: MemoizedSelector, Product[]> - * selectSelectedId, // type: MemoizedSelector + * selectSelectedId, // type: MemoizedSelector, string | null> * } = productsFeature; * ``` * diff --git a/projects/ngrx.io/content/guide/migration/v15.md b/projects/ngrx.io/content/guide/migration/v15.md index 6c58a569de..42d78866de 100644 --- a/projects/ngrx.io/content/guide/migration/v15.md +++ b/projects/ngrx.io/content/guide/migration/v15.md @@ -223,6 +223,34 @@ export class TestComponent { ## Deprecations +### @ngrx/store + +#### Deprecated `createFeature` Signature with Root State (Introduced in v15.2) + +The `createFeature` signature with root state is deprecated in favor of a signature without root state. + +BEFORE: + +```ts +interface AppState { + users: State; +} + +export const usersFeature = createFeature({ + name: 'users', + reducer: createReducer(initialState, /* case reducers */), +}); +``` + +AFTER: + +```ts +export const usersFeature = createFeature({ + name: 'users', + reducer: createReducer(initialState, /* case reducers */), +}); +``` + ### @ngrx/router-store #### Renamed `getSelectors` Function (Introduced in v15.2)