fix(store): remove SelectorWithProps and MemoizedSelectorWithProps#5080
Open
david-shortman wants to merge 4 commits intongrx:mainfrom
Open
fix(store): remove SelectorWithProps and MemoizedSelectorWithProps#5080david-shortman wants to merge 4 commits intongrx:mainfrom
david-shortman wants to merge 4 commits intongrx:mainfrom
Conversation
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Remove all deprecated selector-with-props APIs that were deprecated since v12 (issue ngrx#2980). This includes: - `SelectorWithProps` type from models - `MemoizedSelectorWithProps` interface from selector - 16 `createSelector` overloads accepting `SelectorWithProps` - 2 `createSelectorFactory` overloads returning `MemoizedSelectorWithProps` - `Store.select()` overloads accepting props and string keys - Standalone `select()` operator overloads accepting props and string keys - Related types in mock store/selector testing utilities - ESLint rule references to removed types - Documentation section on selectors with props Adds a v21 migration schematic that removes `SelectorWithProps` and `MemoizedSelectorWithProps` imports from user code, and updates the v21 migration guide with BEFORE/AFTER examples for converting to factory selectors. Closes ngrx#3035 BREAKING CHANGES: `SelectorWithProps` and `MemoizedSelectorWithProps` types have been removed. Use factory selectors instead. BEFORE: const selectCustomer = createSelector( selectCustomers, (customers, props: { customerId: number }) => customers[props.customerId] ); this.store.select(selectCustomer, { customerId: 42 }); AFTER: const selectCustomer = (customerId: number) => createSelector(selectCustomers, (customers) => customers[customerId]); this.store.select(selectCustomer(42)); String-key selectors have also been removed. BEFORE: this.store.select('featureName'); AFTER: this.store.select((state) => state.featureName); Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5ac3e64 to
c80bbc5
Compare
- Fix router-store build: convert string-key select to selector fn - Fix standalone-app: convert string-key select to selector fn - Fix data package test: convert string-key select to selector fn - Migration: add inline TODO comments at select(selector, props) sites - Migration guide: add memoization note and composition pattern - Update API reference docs to reflect removed overloads Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use createSelector to memoize the factory itself, so repeated calls with the same argument return the same inner selector instance. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Member
timdeschryver
left a comment
There was a problem hiding this comment.
This is a big one that needs to be discussed with the team (because it can break many legacy apps).
If it gets accepted the first release that can include this is v22.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove all deprecated
SelectorWithPropsandMemoizedSelectorWithPropstypesand APIs, deprecated since v12 (#2980). Adds a v21 migration schematic that
removes imports, auto-converts string-key selects, and adds inline TODO comments
at
select(selector, props)call sites requiring manual migration. Updates themigration guide with BEFORE/AFTER examples for factory selectors and a memoized
composition pattern.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Closes #3035
What is the new behavior?
SelectorWithPropsandMemoizedSelectorWithPropstypes are removed from@ngrx/storecreateSelectoroverloads accepting selectors with props are removedcreateSelectorFactoryoverloads returningMemoizedSelectorWithPropsare removedStore.select()andselect()operator no longer accept props or string keysdefaultStateFnno longer handles the props branchMockStore,MockSelector) no longer referenceMemoizedSelectorWithPropsprefix-selectors-with-selectno longer checks for removed typesrouter-storeservice,standalone-apppipe,datatestSelectorWithProps/MemoizedSelectorWithPropsimportsselect('key')string-key calls toselect((state: any) => state['key'])// TODOcomments atselect(selector, props)call sites that need manual migrationcreateSelectorto memoize the factory)Does this PR introduce a breaking change?
SelectorWithProps,MemoizedSelectorWithProps, and all related overloads have been removed. Users should migrate to factory selectors. Note that selectors with props did not memoize properly in practice —defaultMemoizeuses strict reference equality (===), so passing inline object literals as props defeated memoization on every change detection cycle.BEFORE:
AFTER (factory selector):
AFTER (memoized factory —
createSelectormemoizes the projector, so repeated calls with the same argument return the same inner selector instance):String-key selectors (
this.store.select('featureName')) have also been removed in favor of selector functions.